|
From: <sv...@va...> - 2005-08-14 06:24:24
|
Author: njn
Date: 2005-08-14 07:24:20 +0100 (Sun, 14 Aug 2005)
New Revision: 4404
Log:
Changed many, but not all, of the VgHashNode* parameters and return
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.
Modified:
trunk/coregrind/m_hashtable.c
trunk/include/pub_tool_hashtable.h
trunk/massif/ms_main.c
trunk/memcheck/mac_malloc_wrappers.c
Modified: trunk/coregrind/m_hashtable.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/coregrind/m_hashtable.c 2005-08-14 04:29:12 UTC (rev 4403)
+++ trunk/coregrind/m_hashtable.c 2005-08-14 06:24:20 UTC (rev 4404)
@@ -40,7 +40,7 @@
#define CHAIN_NO(key,tbl) (((UWord)(key)) % tbl->n_chains)
=20
struct _VgHashTable {
- UInt n_chains; // should be prime
+ UInt n_chains; // should be prime
VgHashNode* chains[0];
};
=20
@@ -71,8 +71,9 @@
=20
/* Puts a new, heap allocated VgHashNode, into the VgHashTable. Prepend=
s
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 =3D (VgHashNode*)vnode;
UInt chain =3D CHAIN_NO(node->key, table);
node->next =3D table->chains[chain];
table->chains[chain] =3D node;
@@ -81,8 +82,8 @@
/* 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 @@
}
=20
/* 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 =3D table->chains[ CHAIN_NO(key, table) ];
=20
@@ -123,7 +124,7 @@
}
=20
/* 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 =3D CHAIN_NO(key, table);
VgHashNode* curr =3D table->chains[chain];
@@ -173,9 +174,9 @@
}
=20
/* 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;
Modified: trunk/include/pub_tool_hashtable.h
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/include/pub_tool_hashtable.h 2005-08-14 04:29:12 UTC (rev 4403)
+++ trunk/include/pub_tool_hashtable.h 2005-08-14 06:24:20 UTC (rev 4404)
@@ -59,19 +59,19 @@
extern Int VG_(HT_count_nodes) ( VgHashTable table );
=20
/* 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 );
=20
/* 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 );
=20
/* 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 );
=20
/* 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 );
=20
/* Allocates an array of pointers to all the shadow chunks of malloc'd
blocks. Must be freed with VG_(free)(). */
@@ -80,9 +80,9 @@
/* 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 );
=20
/* Applies a function f() once to each node. Again, `d' can be used
to pass extra information to the function. */
Modified: trunk/massif/ms_main.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/massif/ms_main.c 2005-08-14 04:29:12 UTC (rev 4403)
+++ trunk/massif/ms_main.c 2005-08-14 06:24:20 UTC (rev 4404)
@@ -690,7 +690,7 @@
if (0 !=3D size)=20
update_XCon(hc->where, size);
}
- VG_(HT_add_node)(malloc_list, (VgHashNode*)hc);
+ VG_(HT_add_node)(malloc_list, hc);
n_heap_blocks++;
=20
// do a census!
@@ -821,7 +821,7 @@
// will have removed and then re-added mc unnecessarily. But that's =
ok
// because shrinking a block with realloc() is (presumably) much rare=
r
// 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);
=20
VGP_POPCC(VgpCliMalloc);
return p_new;
Modified: trunk/memcheck/mac_malloc_wrappers.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/memcheck/mac_malloc_wrappers.c 2005-08-14 04:29:12 UTC (rev 440=
3)
+++ trunk/memcheck/mac_malloc_wrappers.c 2005-08-14 06:24:20 UTC (rev 440=
4)
@@ -212,8 +212,7 @@
// Only update this stat if allocation succeeded.
cmalloc_bs_mallocd +=3D size;
=20
- VG_(HT_add_node)( table,=20
- (VgHashNode*)create_MAC_Chunk(tid, p, size, kind) )=
;
+ VG_(HT_add_node)( table, create_MAC_Chunk(tid, p, size, kind) );
=20
MAC_(ban_mem_heap)( p-rzB, rzB );
MAC_(new_mem_heap)( p, size, is_zeroed );
@@ -417,7 +416,7 @@
// will have removed and then re-added mc unnecessarily. But that's =
ok
// because shrinking a block with realloc() is (presumably) much rare=
r
// 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 );
=20
VGP_POPCC(VgpCliMalloc);
return p_new;
@@ -444,7 +443,7 @@
VG_(tool_panic)("MAC_(create_mempool): shadow area is accessible")=
;
}=20
=20
- VG_(HT_add_node)( MAC_(mempool_list), (VgHashNode*)mp );
+ VG_(HT_add_node)( MAC_(mempool_list), mp );
=20
}
=20
@@ -525,7 +524,8 @@
}
MallocStats;
=20
-static void malloc_stats_count_chunk(VgHashNode* node, void* d) {
+static void malloc_stats_count_chunk(VgHashNode* node, void* d)=20
+{
MAC_Chunk* mc =3D (MAC_Chunk*)node;
MallocStats *ms =3D (MallocStats *)d;
=20
|