Author: florian
Date: Thu Sep 11 20:15:23 2014
New Revision: 14516
Log:
Rename VG_(malloc_usable_size) to VG_(cli_malloc_usable_size)
because it operates on the CLIENT arena. Given that VG_(malloc)
operates on the CORE arena, it was unexpected for VG_(mallos_usable_size)
to use a different arena.
Move function definition to the proper place (next to VG_(cli_malloc))
and fix call sites.
Modified:
trunk/coregrind/m_mallocfree.c
trunk/coregrind/m_replacemalloc/replacemalloc_core.c
trunk/exp-dhat/dh_main.c
trunk/include/pub_tool_mallocfree.h
trunk/include/pub_tool_replacemalloc.h
trunk/massif/ms_main.c
Modified: trunk/coregrind/m_mallocfree.c
==============================================================================
--- trunk/coregrind/m_mallocfree.c (original)
+++ trunk/coregrind/m_mallocfree.c Thu Sep 11 20:15:23 2014
@@ -2599,12 +2599,6 @@
return VG_(arena_strdup) ( VG_AR_CORE, cc, s );
}
-// Useful for querying user blocks.
-SizeT VG_(malloc_usable_size) ( void* p )
-{
- return VG_(arena_malloc_usable_size)(VG_AR_CLIENT, p);
-}
-
void* VG_(perm_malloc) ( SizeT size, Int align )
{
return VG_(arena_perm_malloc) ( VG_AR_CORE, size, align );
Modified: trunk/coregrind/m_replacemalloc/replacemalloc_core.c
==============================================================================
--- trunk/coregrind/m_replacemalloc/replacemalloc_core.c (original)
+++ trunk/coregrind/m_replacemalloc/replacemalloc_core.c Thu Sep 11 20:15:23 2014
@@ -101,6 +101,12 @@
VG_(arena_free) ( VG_AR_CLIENT, p );
}
+// Useful for querying user blocks.
+SizeT VG_(cli_malloc_usable_size) ( void* p )
+{
+ return VG_(arena_malloc_usable_size)(VG_AR_CLIENT, p);
+}
+
Bool VG_(addr_is_in_block)( Addr a, Addr start, SizeT size, SizeT rz_szB )
{
return ( start - rz_szB <= a && a < start + size + rz_szB );
Modified: trunk/exp-dhat/dh_main.c
==============================================================================
--- trunk/exp-dhat/dh_main.c (original)
+++ trunk/exp-dhat/dh_main.c Thu Sep 11 20:15:23 2014
@@ -466,7 +466,7 @@
return NULL;
}
if (is_zeroed) VG_(memset)(p, 0, req_szB);
- actual_szB = VG_(malloc_usable_size)(p);
+ actual_szB = VG_(cli_malloc_usable_size)(p);
tl_assert(actual_szB >= req_szB);
/* slop_szB = actual_szB - req_szB; */
} else {
Modified: trunk/include/pub_tool_mallocfree.h
==============================================================================
--- trunk/include/pub_tool_mallocfree.h (original)
+++ trunk/include/pub_tool_mallocfree.h Thu Sep 11 20:15:23 2014
@@ -45,10 +45,6 @@
extern void* VG_(realloc) ( const HChar* cc, void* p, SizeT size );
extern HChar* VG_(strdup) ( const HChar* cc, const HChar* s );
-// Returns the usable size of a heap-block. It's the asked-for size plus
-// possibly some more due to rounding up.
-extern SizeT VG_(malloc_usable_size)( void* p );
-
// TODO: move somewhere else
// Call here to bomb the system when out of memory (mmap anon fails)
__attribute__((noreturn))
@@ -60,8 +56,7 @@
// on a multiple of align.
// Use the macro vg_alignof (type) to get a safe alignment for a type.
// No other function can be used on these permanently allocated blocks.
-// In particular, do *not* call VG_(free) or VG_(malloc_usable_size)
-// or VG_(realloc).
+// In particular, do *not* call VG_(free) or VG_(realloc).
// Technically, these blocks will be returned from big superblocks
// only containing such permanently allocated blocks.
// Note that there is no cc cost centre : all such blocks will be
Modified: trunk/include/pub_tool_replacemalloc.h
==============================================================================
--- trunk/include/pub_tool_replacemalloc.h (original)
+++ trunk/include/pub_tool_replacemalloc.h Thu Sep 11 20:15:23 2014
@@ -42,6 +42,10 @@
* alloc/freeing. */
extern void* VG_(cli_malloc) ( SizeT align, SizeT nbytes );
extern void VG_(cli_free) ( void* p );
+// Returns the usable size of a heap-block. It's the asked-for size plus
+// possibly some more due to rounding up.
+extern SizeT VG_(cli_malloc_usable_size)( void* p );
+
/* If a tool uses deferred freeing (e.g. memcheck to catch accesses to
freed memory) it can maintain number and total size of queued blocks
Modified: trunk/massif/ms_main.c
==============================================================================
--- trunk/massif/ms_main.c (original)
+++ trunk/massif/ms_main.c Thu Sep 11 20:15:23 2014
@@ -1567,7 +1567,7 @@
return NULL;
}
if (is_zeroed) VG_(memset)(p, 0, req_szB);
- actual_szB = VG_(malloc_usable_size)(p);
+ actual_szB = VG_(cli_malloc_usable_size)(p);
tl_assert(actual_szB >= req_szB);
slop_szB = actual_szB - req_szB;
@@ -1682,7 +1682,7 @@
}
VG_(memcpy)(p_new, p_old, old_req_szB + old_slop_szB);
VG_(cli_free)(p_old);
- new_actual_szB = VG_(malloc_usable_size)(p_new);
+ new_actual_szB = VG_(cli_malloc_usable_size)(p_new);
tl_assert(new_actual_szB >= new_req_szB);
new_slop_szB = new_actual_szB - new_req_szB;
}
|