aboutsummaryrefslogtreecommitdiff
path: root/include/pub_tool_hashtable.h
diff options
context:
space:
mode:
authorflorian <florian@a5019735-40e9-0310-863c-91ae7b9d1cf9>2014-10-18 10:58:05 +0000
committerflorian <florian@a5019735-40e9-0310-863c-91ae7b9d1cf9>2014-10-18 10:58:05 +0000
commit09a4c794458cdb9dea743fa40e450150a2725257 (patch)
treec84b63735983c78a373c8498d4beca3f118a70d5 /include/pub_tool_hashtable.h
parent801c199ed5055bed3196db64af09adf69af650a8 (diff)
downloadvalgrind-09a4c794458cdb9dea743fa40e450150a2725257.tar.gz
Change the definition of VgHashTable to not have pointer type.
This is (a) consistent with how the other containers are defined and, more importantly, (b) allows the constification of the hash table API. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14639 a5019735-40e9-0310-863c-91ae7b9d1cf9
Diffstat (limited to 'include/pub_tool_hashtable.h')
-rw-r--r--include/pub_tool_hashtable.h29
1 files changed, 16 insertions, 13 deletions
diff --git a/include/pub_tool_hashtable.h b/include/pub_tool_hashtable.h
index 21dd0b234..b105ac404 100644
--- a/include/pub_tool_hashtable.h
+++ b/include/pub_tool_hashtable.h
@@ -49,28 +49,28 @@ typedef
}
VgHashNode;
-typedef struct _VgHashTable * VgHashTable;
+typedef struct _VgHashTable VgHashTable;
/* Make a new table. Allocates the memory with VG_(calloc)(), so can
be freed with VG_(free)(). The table starts small but will
periodically be expanded. This is transparent to the users of this
module. The function never returns NULL. */
-extern VgHashTable VG_(HT_construct) ( const HChar* name );
+extern VgHashTable *VG_(HT_construct) ( const HChar* name );
/* Count the number of nodes in a table. */
-extern Int VG_(HT_count_nodes) ( VgHashTable table );
+extern Int VG_(HT_count_nodes) ( const VgHashTable *table );
/* Add a node to the table. Duplicate keys are permitted. */
-extern void VG_(HT_add_node) ( VgHashTable t, void* node );
+extern void VG_(HT_add_node) ( VgHashTable *t, void* node );
/* Looks up a VgHashNode by key in the table.
* Returns NULL if not found. If entries
* with duplicate keys are present, the most recently-added of the dups will
* be returned, but it's probably better to avoid dups altogether. */
-extern void* VG_(HT_lookup) ( VgHashTable table, UWord key );
+extern void* VG_(HT_lookup) ( const VgHashTable *table, UWord key );
/* Removes a VgHashNode by key from the table. Returns NULL if not found. */
-extern void* VG_(HT_remove) ( VgHashTable table, UWord key );
+extern void* VG_(HT_remove) ( VgHashTable *table, UWord key );
typedef Word (*HT_Cmp_t) ( const void* node1, const void* node2 );
@@ -85,22 +85,25 @@ typedef Word (*HT_Cmp_t) ( const void* node1, const void* node2 );
between components, either the node memory should be fully initialised
(e.g. allocated using VG_(calloc)) or each component should be compared
individually. */
-extern void* VG_(HT_gen_lookup) ( VgHashTable table, void* node, HT_Cmp_t cmp );
-extern void* VG_(HT_gen_remove) ( VgHashTable table, void* node, HT_Cmp_t cmp );
+extern void* VG_(HT_gen_lookup) ( const VgHashTable *table, const void* node,
+ HT_Cmp_t cmp );
+extern void* VG_(HT_gen_remove) ( VgHashTable *table, const void* node,
+ HT_Cmp_t cmp );
/* Output detailed usage/collision statistics.
cmp will be used to verify if 2 elements with the same key are equal.
Use NULL cmp if the hash table elements are only to be compared by key. */
-extern void VG_(HT_print_stats) ( VgHashTable table, HT_Cmp_t cmp );
+extern void VG_(HT_print_stats) ( const VgHashTable *table, HT_Cmp_t cmp );
/* Allocates a suitably-sized array, copies pointers to all the hashtable
elements into it, then returns both the array and the size of it. The
array must be freed with VG_(free). If the hashtable is empty, the
function returns NULL and assigns *nelems = 0. */
-extern VgHashNode** VG_(HT_to_array) ( VgHashTable t, /*OUT*/ UInt* n_elems );
+extern VgHashNode** VG_(HT_to_array) ( const VgHashTable *table,
+ /*OUT*/ UInt* n_elems );
/* Reset the table's iterator to point to the first element. */
-extern void VG_(HT_ResetIter) ( VgHashTable table );
+extern void VG_(HT_ResetIter) ( VgHashTable *table );
/* Return the element pointed to by the iterator and move on to the
next one. Returns NULL if the last one has been passed, or if
@@ -113,11 +116,11 @@ extern void VG_(HT_ResetIter) ( VgHashTable table );
Since resizing only happens as a result of calling HT_add_node,
disallowing HT_add_node during iteration should give the required
assurance. */
-extern void* VG_(HT_Next) ( VgHashTable table );
+extern void* VG_(HT_Next) ( VgHashTable *table );
/* Destroy a table and deallocates the memory used by the nodes using
freenode_fn.*/
-extern void VG_(HT_destruct) ( VgHashTable t, void(*freenode_fn)(void*) );
+extern void VG_(HT_destruct) ( VgHashTable *table, void(*freenode_fn)(void*) );
#endif // __PUB_TOOL_HASHTABLE_H