<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/> <title>SphinxBase: hash_entry_s Struct Reference</title> <link href="tabs.css" rel="stylesheet" type="text/css"/> <link href="navtree.css" rel="stylesheet" type="text/css"/> <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript" src="navtree.js"></script> <script type="text/javascript" src="resize.js"></script> <script type="text/javascript"> $(document).ready(initResizable); </script> <link href="doxygen.css" rel="stylesheet" type="text/css"/> </head> <body> <!-- Generated by Doxygen 1.7.3 --> <div id="top"> <div id="titlearea"> <table cellspacing="0" cellpadding="0"> <tbody> <tr style="height: 56px;"> <td style="padding-left: 0.5em;"> <div id="projectname">SphinxBase <span id="projectnumber">0.6</span></div> </td> </tr> </tbody> </table> </div> <div id="navrow1" class="tabs"> <ul class="tablist"> <li><a href="index.html"><span>Main Page</span></a></li> <li><a href="pages.html"><span>Related Pages</span></a></li> <li class="current"><a href="annotated.html"><span>Data Structures</span></a></li> <li><a href="files.html"><span>Files</span></a></li> </ul> </div> <div id="navrow2" class="tabs2"> <ul class="tablist"> <li><a href="annotated.html"><span>Data Structures</span></a></li> <li><a href="functions.html"><span>Data Fields</span></a></li> </ul> </div> </div> <div id="side-nav" class="ui-resizable side-nav-resizable"> <div id="nav-tree"> <div id="nav-tree-contents"> </div> </div> <div id="splitbar" style="-moz-user-select:none;" class="ui-resizable-handle"> </div> </div> <script type="text/javascript"> initNavTree('structhash__entry__s.html',''); </script> <div id="doc-content"> <div class="header"> <div class="summary"> <a href="#pub-attribs">Data Fields</a> </div> <div class="headertitle"> <h1>hash_entry_s Struct Reference</h1> </div> </div> <div class="contents"> <!-- doxytag: class="hash_entry_s" --> <p>A note by ARCHAN at 20050510: Technically what we use is so-called "hash table with buckets" which is very nice way to deal with external hashing. <a href="#_details">More...</a></p> <p><code>#include <<a class="el" href="hash__table_8h_source.html">hash_table.h</a>></code></p> <table class="memberdecls"> <tr><td colspan="2"><h2><a name="pub-attribs"></a> Data Fields</h2></td></tr> <tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a2566ac1233761789585363a283385321"></a><!-- doxytag: member="hash_entry_s::key" ref="a2566ac1233761789585363a283385321" args="" --> const char * </td><td class="memItemRight" valign="bottom"><b>key</b></td></tr> <tr><td class="memItemLeft" align="right" valign="top">size_t </td><td class="memItemRight" valign="bottom"><a class="el" href="structhash__entry__s.html#af1ec5f16059ced6d9a8ae4d36ca7e2b3">len</a></td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Key string, NULL if this is an empty slot. <a href="#af1ec5f16059ced6d9a8ae4d36ca7e2b3"></a><br/></td></tr> <tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a0d57012963084fed93886681108aa636"></a><!-- doxytag: member="hash_entry_s::val" ref="a0d57012963084fed93886681108aa636" args="" --> void * </td><td class="memItemRight" valign="bottom"><a class="el" href="structhash__entry__s.html#a0d57012963084fed93886681108aa636">val</a></td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Key-length; the key string does not have to be a C-style NULL terminated string; it can have arbitrary binary bytes. <br/></td></tr> <tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="aa855ac854b9c36cf23f60d9ac8093e7f"></a><!-- doxytag: member="hash_entry_s::next" ref="aa855ac854b9c36cf23f60d9ac8093e7f" args="" --> struct <a class="el" href="structhash__entry__s.html">hash_entry_s</a> * </td><td class="memItemRight" valign="bottom"><a class="el" href="structhash__entry__s.html#aa855ac854b9c36cf23f60d9ac8093e7f">next</a></td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Value associated with above key. <br/></td></tr> </table> <hr/><a name="_details"></a><h2>Detailed Description</h2> <div class="textblock"><p>A note by ARCHAN at 20050510: Technically what we use is so-called "hash table with buckets" which is very nice way to deal with external hashing. </p> <p>There are definitely better ways to do internal hashing (i.e. when everything is stored in the memory.) In Sphinx 3, this is a reasonable practice because hash table is only used in lookup in initialization or in lookups which is not critical for speed. Another note by ARCHAN at 20050703: To use this data structure properly, it is very important to realize that the users are required to handle memory allocation of the C-style keys. The hash table will not make a copy of the memory allocated for any of the C-style key. It will not allocate memory for it. It will not delete memory for it. As a result, the following code sniplet will cause memory leak.</p> <p>while (1){ str=(char*)ckd_calloc(str_length,sizeof(char*)) if(hash_enter(ht,str,id)!=id){ printf("fail to add key str %s with val id %d\n",str,id)} } A note by dhuggins on 20061010: Changed this to use void * instead of int32 as the value type, so that arbitrary objects can be inserted into a hash table (in a way that won't crash on 64-bit machines ;) The hash table structures. Each hash table is identified by a <a class="el" href="structhash__table__t.html">hash_table_t</a> structure. hash_table_t.table is pre-allocated for a user-controlled max size, and is initially empty. As new entries are created (using hash_enter()), the empty entries get filled. If multiple keys hash to the same entry, new entries are allocated and linked together in a linear list. </p> <p>Definition at line <a class="el" href="hash__table_8h_source.html#l00149">149</a> of file <a class="el" href="hash__table_8h_source.html">hash_table.h</a>.</p> </div><hr/><h2>Field Documentation</h2> <a class="anchor" id="af1ec5f16059ced6d9a8ae4d36ca7e2b3"></a><!-- doxytag: member="hash_entry_s::len" ref="af1ec5f16059ced6d9a8ae4d36ca7e2b3" args="" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">size_t <a class="el" href="structhash__entry__s.html#af1ec5f16059ced6d9a8ae4d36ca7e2b3">hash_entry_s::len</a></td> </tr> </table> </div> <div class="memdoc"> <p>Key string, NULL if this is an empty slot. </p> <p>NOTE that the key must not be changed once the entry has been made. </p> <p>Definition at line <a class="el" href="hash__table_8h_source.html#l00153">153</a> of file <a class="el" href="hash__table_8h_source.html">hash_table.h</a>.</p> <p>Referenced by <a class="el" href="hash__table_8c_source.html#l00580">hash_table_display()</a>.</p> </div> </div> <hr/>The documentation for this struct was generated from the following file:<ul> <li>include/sphinxbase/<a class="el" href="hash__table_8h_source.html">hash_table.h</a></li> </ul> </div> </div> <div id="nav-path" class="navpath"> <ul> <li class="navelem"><a class="el" href="structhash__entry__s.html">hash_entry_s</a> </li> <li class="footer">Generated on Tue Apr 19 2011 for SphinxBase by  <a href="http://www.doxygen.org/index.html"> <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.3 </li> </ul> </div> </body> </html>