|
From: <sv...@va...> - 2005-08-16 03:29:56
|
Author: njn
Date: 2005-08-16 04:29:50 +0100 (Tue, 16 Aug 2005)
New Revision: 4432
Log:
lots of little wibbles
Modified:
trunk/coregrind/m_oset.c
trunk/massif/ms_main.c
trunk/memcheck/mac_malloc_wrappers.c
Modified: trunk/coregrind/m_oset.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_oset.c 2005-08-16 03:28:47 UTC (rev 4431)
+++ trunk/coregrind/m_oset.c 2005-08-16 03:29:50 UTC (rev 4432)
@@ -724,4 +724,3 @@
/*--------------------------------------------------------------------*/
/*--- end ---*/
/*--------------------------------------------------------------------*/
-
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-16 03:28:47 UTC (rev 4431)
+++ trunk/massif/ms_main.c 2005-08-16 03:29:50 UTC (rev 4432)
@@ -711,7 +711,7 @@
n_frees++;
=20
// Remove HP_Chunk from malloc_list
- hc =3D (HP_Chunk*)VG_(HT_remove)(malloc_list, (UWord)p);
+ hc =3D VG_(HT_remove)(malloc_list, (UWord)p);
if (NULL =3D=3D hc)
return; // must have been a bogus free()
tl_assert(n_heap_blocks > 0);
@@ -783,7 +783,7 @@
VGP_PUSHCC(VgpCliMalloc);
=20
// First try and find the block.
- hc =3D (HP_Chunk*)VG_(HT_remove)(malloc_list, (UWord)p_old);
+ hc =3D VG_(HT_remove)(malloc_list, (UWord)p_old);
if (hc =3D=3D NULL) {
VGP_POPCC(VgpCliMalloc);
return NULL; // must have been a bogus realloc()
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-16 03:28:47 UTC (rev 443=
1)
+++ trunk/memcheck/mac_malloc_wrappers.c 2005-08-16 03:29:50 UTC (rev 443=
2)
@@ -67,12 +67,10 @@
/*--- Tracking malloc'd and free'd blocks ---*/
/*------------------------------------------------------------*/
=20
-/* Record malloc'd blocks. Nb: Addrcheck and Memcheck construct this
- separately in their respective initialisation functions. */
+/* Record malloc'd blocks. */
VgHashTable MAC_(malloc_list) =3D NULL;
=20
-/* Memory pools. Nb: Addrcheck and Memcheck construct this separately
- in their respective initialisation functions. */
+/* Memory pools. */
VgHashTable MAC_(mempool_list) =3D NULL;
=20
/* Records blocks after freeing. */
@@ -84,8 +82,6 @@
some of the oldest blocks in the queue at the same time. */
static void add_to_freed_queue ( MAC_Chunk* mc )
{
- MAC_Chunk* mc1;
-
/* Put it at the end of the freed list */
if (freed_list_end =3D=3D NULL) {
tl_assert(freed_list_start =3D=3D NULL);
@@ -103,6 +99,8 @@
volume below vg_clo_freelist_vol. */
=20
while (freed_list_volume > MAC_(clo_freelist_vol)) {
+ MAC_Chunk* mc1;
+
tl_assert(freed_list_start !=3D NULL);
tl_assert(freed_list_end !=3D NULL);
=20
@@ -140,11 +138,10 @@
mc->allockind =3D kind;
mc->where =3D VG_(record_ExeContext)(tid);
=20
- /* Paranoia ... ensure this area is off-limits to the client, so
+ /* Paranoia ... ensure the MAC_Chunk is off-limits to the client, so
the mc->data field isn't visible to the leak checker. If memory
- management is working correctly, anything pointer returned by
- VG_(malloc) should be noaccess as far as the client is
- concerned. */
+ management is working correctly, any pointer returned by VG_(mallo=
c)
+ should be noaccess as far as the client is concerned. */
if (!MAC_(check_noaccess)( (Addr)mc, sizeof(MAC_Chunk), NULL )) {
VG_(tool_panic)("create_MAC_Chunk: shadow area is accessible");
}=20
@@ -296,20 +293,17 @@
=20
cmalloc_n_frees++;
=20
- mc =3D (MAC_Chunk*)VG_(HT_remove) ( MAC_(malloc_list), (UWord)p );
+ mc =3D VG_(HT_remove) ( MAC_(malloc_list), (UWord)p );
if (mc =3D=3D NULL) {
MAC_(record_free_error) ( tid, p );
- VGP_POPCC(VgpCliMalloc);
- return;
+ } else {
+ /* check if its a matching free() / delete / delete [] */
+ if (kind !=3D mc->allockind) {
+ MAC_(record_freemismatch_error) ( tid, p, mc );
+ }
+ die_and_free_mem ( tid, mc, rzB );
}
=20
- /* check if its a matching free() / delete / delete [] */
- if (kind !=3D mc->allockind) {
- MAC_(record_freemismatch_error) ( tid, p, mc );
- }
-
- die_and_free_mem ( tid, mc, rzB );
-
VGP_POPCC(VgpCliMalloc);
}
=20
@@ -347,10 +341,10 @@
return NULL;
=20
/* Remove the old block */
- mc =3D (MAC_Chunk*)VG_(HT_remove) ( MAC_(malloc_list), (UWord)p_old )=
;
+ mc =3D VG_(HT_remove) ( MAC_(malloc_list), (UWord)p_old );
if (mc =3D=3D NULL) {
MAC_(record_free_error) ( tid, (Addr)p_old );
- /* Perhaps we should return to the program regardless. */
+ /* We return to the program regardless. */
VGP_POPCC(VgpCliMalloc);
return NULL;
}
@@ -416,14 +410,12 @@
=20
void MAC_(create_mempool)(Addr pool, UInt rzB, Bool is_zeroed)
{
- MAC_Mempool* mp;
+ MAC_Mempool* mp =3D VG_(malloc)(sizeof(MAC_Mempool));
+ mp->pool =3D pool;
+ mp->rzB =3D rzB;
+ mp->is_zeroed =3D is_zeroed;
+ mp->chunks =3D VG_(HT_construct)( 3001 ); // prime, not so big
=20
- mp =3D VG_(malloc)(sizeof(MAC_Mempool));
- mp->pool =3D pool;
- mp->rzB =3D rzB;
- mp->is_zeroed =3D is_zeroed;
- mp->chunks =3D VG_(HT_construct)( 3001 ); // prime, not so big
-
/* Paranoia ... ensure this area is off-limits to the client, so
the mp->data field isn't visible to the leak checker. If memory
management is working correctly, anything pointer returned by
@@ -434,7 +426,6 @@
}=20
=20
VG_(HT_add_node)( MAC_(mempool_list), mp );
- =20
}
=20
void MAC_(destroy_mempool)(Addr pool)
@@ -467,17 +458,14 @@
=20
void MAC_(mempool_alloc)(ThreadId tid, Addr pool, Addr addr, SizeT size)
{
- MAC_Mempool* mp;
+ MAC_Mempool* mp =3D VG_(HT_lookup) ( MAC_(mempool_list), (UWord)pool =
);
=20
- mp =3D VG_(HT_lookup) ( MAC_(mempool_list), (UWord)pool );
-
if (mp =3D=3D NULL) {
MAC_(record_illegal_mempool_error) ( tid, pool );
- return;
+ } else {
+ MAC_(new_block)(tid, addr, size, /*ignored*/0, mp->rzB, mp->is_zer=
oed,
+ MAC_AllocCustom, mp->chunks);
}
-
- MAC_(new_block)(tid, addr, size, /*ignored*/0, mp->rzB, mp->is_zeroed=
,
- MAC_AllocCustom, mp->chunks);
}
=20
void MAC_(mempool_free)(Addr pool, Addr addr)
@@ -492,7 +480,7 @@
return;
}
=20
- mc =3D (MAC_Chunk*)VG_(HT_remove)(mp->chunks, (UWord)addr);
+ mc =3D VG_(HT_remove)(mp->chunks, (UWord)addr);
if (mc =3D=3D NULL) {
MAC_(record_free_error)(tid, (Addr)addr);
return;
|