]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Changed many, but not all, of the VgHashNode* parameters and return
authorNicholas Nethercote <njn@valgrind.org>
Sun, 14 Aug 2005 06:24:20 +0000 (06:24 +0000)
committerNicholas Nethercote <njn@valgrind.org>
Sun, 14 Aug 2005 06:24:20 +0000 (06:24 +0000)
types in m_hashtable.c to void*.  This requires no changes to code
already using VgHashTables, but it allows some previously-required casts
to be removed.  I also changed Memcheck and Massif by removing some of
these now-unnecessary casts.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@4404

coregrind/m_hashtable.c
include/pub_tool_hashtable.h
massif/ms_main.c
memcheck/mac_malloc_wrappers.c

index 7aef05dd0de44f836ba4dd7eaaa5a54e646389b7..cbb88863963d415e7bf29ed1abe5a98496fc767b 100644 (file)
@@ -40,7 +40,7 @@
 #define CHAIN_NO(key,tbl) (((UWord)(key)) % tbl->n_chains)
 
 struct _VgHashTable {
-   UInt        n_chains;     // should be prime
+   UInt        n_chains;      // should be prime
    VgHashNode* chains[0];
 };
 
@@ -71,8 +71,9 @@ Int VG_(HT_count_nodes) ( VgHashTable table )
 
 /* Puts a new, heap allocated VgHashNode, into the VgHashTable.  Prepends
    the node to the appropriate chain. */
-void VG_(HT_add_node) ( VgHashTable table, VgHashNode* node )
+void VG_(HT_add_node) ( VgHashTable table, void* vnode )
 {
+   VgHashNode* node     = (VgHashNode*)vnode;
    UInt chain           = CHAIN_NO(node->key, table);
    node->next           = table->chains[chain];
    table->chains[chain] = node;
@@ -81,8 +82,8 @@ void VG_(HT_add_node) ( VgHashTable table, VgHashNode* node )
 /* Looks up a VgHashNode in the table.  Also returns the address of
    the previous node's 'next' pointer which allows it to be removed from the
    list later without having to look it up again.  */
-VgHashNode* VG_(HT_get_node) ( VgHashTable table, UWord key,
-                               /*OUT*/VgHashNode*** next_ptr )
+void* VG_(HT_get_node) ( VgHashTable table, UWord key,
+                         /*OUT*/VgHashNode*** next_ptr )
 {
    VgHashNode *prev, *curr;
    Int       chain;
@@ -109,7 +110,7 @@ VgHashNode* VG_(HT_get_node) ( VgHashTable table, UWord key,
 }
 
 /* Looks up a VgHashNode in the table.  Returns NULL if not found. */
-VgHashNode* VG_(HT_lookup) ( VgHashTable table, UWord key )
+void* VG_(HT_lookup) ( VgHashTable table, UWord key )
 {
    VgHashNode* curr = table->chains[ CHAIN_NO(key, table) ];
 
@@ -123,7 +124,7 @@ VgHashNode* VG_(HT_lookup) ( VgHashTable table, UWord key )
 }
 
 /* Removes a VgHashNode from the table.  Returns NULL if not found. */
-VgHashNode* VG_(HT_remove) ( VgHashTable table, UWord key )
+void* VG_(HT_remove) ( VgHashTable table, UWord key )
 {
    Int          chain         = CHAIN_NO(key, table);
    VgHashNode*  curr          =   table->chains[chain];
@@ -173,9 +174,9 @@ VgHashNode** VG_(HT_to_array) ( VgHashTable table, /*OUT*/ UInt* n_shadows )
 }
 
 /* Return the first VgHashNode satisfying the predicate p. */
-VgHashNode* VG_(HT_first_match) ( VgHashTable table,
-                                  Bool (*p) ( VgHashNode*, void* ),
-                                  void* d )
+void* VG_(HT_first_match) ( VgHashTable table,
+                             Bool (*p) ( VgHashNode*, void* ),
+                             void* d )
 {
    UInt      i;
    VgHashNode* node;
index ec065f98ec37462108c447a7f504da7f30f4a39f..165fefdf8ab0fe28ea82baae6edbb866edcfbf02 100644 (file)
@@ -59,19 +59,19 @@ extern VgHashTable VG_(HT_construct) ( UInt n_chains );
 extern Int VG_(HT_count_nodes) ( VgHashTable table );
 
 /* Add a node to the table. */
-extern void VG_(HT_add_node) ( VgHashTable t, VgHashNode* node );
+extern void VG_(HT_add_node) ( VgHashTable t, void* node );
 
 /* Looks up a node in the hash table.  Also returns the address of the
    previous node's `next' pointer which allows it to be removed from the
    list later without having to look it up again.  */
-extern VgHashNode* VG_(HT_get_node) ( VgHashTable t, UWord key,
+extern void* VG_(HT_get_node) ( VgHashTable t, UWord key,
                                     /*OUT*/VgHashNode*** next_ptr );
 
 /* Looks up a VgHashNode in the table.  Returns NULL if not found. */
-extern VgHashNode* VG_(HT_lookup) ( VgHashTable table, UWord key );
+extern void* VG_(HT_lookup) ( VgHashTable table, UWord key );
 
 /* Removes a VgHashNode from the table.  Returns NULL if not found. */
-extern VgHashNode* VG_(HT_remove) ( VgHashTable table, UWord key );
+extern void* VG_(HT_remove) ( VgHashTable table, UWord key );
 
 /* Allocates an array of pointers to all the shadow chunks of malloc'd
    blocks.  Must be freed with VG_(free)(). */
@@ -80,9 +80,9 @@ extern VgHashNode** VG_(HT_to_array) ( VgHashTable t, /*OUT*/ UInt* n_shadows );
 /* Returns first node that matches predicate `p', or NULL if none do.
    Extra arguments can be implicitly passed to `p' using `d' which is an
    opaque pointer passed to `p' each time it is called. */
-extern VgHashNode* VG_(HT_first_match) ( VgHashTable t,
-                                         Bool (*p)(VgHashNode*, void*),
-                                         void* d );
+extern void* VG_(HT_first_match) ( VgHashTable t,
+                                   Bool (*p)(VgHashNode*, void*),
+                                   void* d );
 
 /* Applies a function f() once to each node.  Again, `d' can be used
    to pass extra information to the function. */
index bff4de53980369e683811b23950abd7c05a065b4..7a278ca687dd95c949b9c69c998088ef8ecf828d 100644 (file)
@@ -690,7 +690,7 @@ void* new_block ( ThreadId tid, void* p, SizeT size, SizeT align,
       if (0 != size) 
          update_XCon(hc->where, size);
    }
-   VG_(HT_add_node)(malloc_list, (VgHashNode*)hc);
+   VG_(HT_add_node)(malloc_list, hc);
    n_heap_blocks++;
 
    // do a census!
@@ -821,7 +821,7 @@ static void* ms_realloc ( ThreadId tid, void* p_old, SizeT new_size )
    // will have removed and then re-added mc unnecessarily.  But that's ok
    // because shrinking a block with realloc() is (presumably) much rarer
    // than growing it, and this way simplifies the growing case.
-   VG_(HT_add_node)(malloc_list, (VgHashNode*)hc);
+   VG_(HT_add_node)(malloc_list, hc);
 
    VGP_POPCC(VgpCliMalloc);
    return p_new;
index de6fac134d229e8326e0ae154e9e3691e9add6af..92a29477b372ed93ec8d675e5f731eb5baaed794 100644 (file)
@@ -212,8 +212,7 @@ void* MAC_(new_block) ( ThreadId tid,
    // Only update this stat if allocation succeeded.
    cmalloc_bs_mallocd += size;
 
-   VG_(HT_add_node)( table, 
-                     (VgHashNode*)create_MAC_Chunk(tid, p, size, kind) );
+   VG_(HT_add_node)( table, create_MAC_Chunk(tid, p, size, kind) );
 
    MAC_(ban_mem_heap)( p-rzB, rzB );
    MAC_(new_mem_heap)( p, size, is_zeroed );
@@ -417,7 +416,7 @@ void* MAC_(realloc) ( ThreadId tid, void* p_old, SizeT new_size )
    // will have removed and then re-added mc unnecessarily.  But that's ok
    // because shrinking a block with realloc() is (presumably) much rarer
    // than growing it, and this way simplifies the growing case.
-   VG_(HT_add_node)( MAC_(malloc_list), (VgHashNode*)mc );
+   VG_(HT_add_node)( MAC_(malloc_list), mc );
 
    VGP_POPCC(VgpCliMalloc);
    return p_new;
@@ -444,7 +443,7 @@ void MAC_(create_mempool)(Addr pool, UInt rzB, Bool is_zeroed)
       VG_(tool_panic)("MAC_(create_mempool): shadow area is accessible");
    } 
 
-   VG_(HT_add_node)( MAC_(mempool_list), (VgHashNode*)mp );
+   VG_(HT_add_node)( MAC_(mempool_list), mp );
    
 }
 
@@ -525,7 +524,8 @@ typedef
    }
    MallocStats;
 
-static void malloc_stats_count_chunk(VgHashNode* node, void* d) {
+static void malloc_stats_count_chunk(VgHashNode* node, void* d) 
+{
    MAC_Chunk* mc = (MAC_Chunk*)node;
    MallocStats *ms = (MallocStats *)d;