title: st_table, st_data_t
body: <p><strong>This is regarding RUBY source code. The structures st_* are in</strong> <b><a href="https://raw.github.com/ruby/ruby/9060e87fa88155a203b69aeb2f05319b20796465/st.c" rel="nofollow">st.c</a> </b></p>
  
  <p>I have a structure</p>
  
  <pre><code>typedef struct TrieNode {
  VALUE loadpath;
  int expired;
  st_table* dirs;
  st_table* fileToAbsPath;
  }TrieNode;
  </code></pre>
  
  <p>I need to be able to store and retrieve it using <strong>st_table</strong>, my key is a <strong>char*</strong> and my value is <strong>TrieNode*</strong>.</p>
  
  <p>To store it I have used the following line where child is of the type <strong>TrieNode*</strong>,</p>
  
  <pre><code>//root-&gt;dirst is st_table*, child is TrieNode*, dirName is char*
  st_add_direct(root-&gt;dirs, (st_data_t)dirName, (st_data_t)child);
  </code></pre>
  
  <p>To retrieve it I was planning on using</p>
  
  <pre><code>st_data_t buff;
  //root-&gt;fileToAbsPath is st_table*, fname is char*
  st_lookup(root-&gt;fileToAbsPath, (st_data_t)fname, &amp;buff);
  </code></pre>
  
  <p>I don't know how to convert <code>buff</code> to <code>TrieNode*</code>.</p>