From: Florian Krohm Date: Sun, 15 Sep 2013 09:18:03 +0000 (+0000) Subject: Move a function and its prototype VG_(malloc_effective_client_redzone_size) X-Git-Tag: svn/VALGRIND_3_9_0~145 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e4c80fed1ec0a4ba8cddc3ffbec6c84cb8a5326c;p=thirdparty%2Fvalgrind.git Move a function and its prototype VG_(malloc_effective_client_redzone_size) to a conceptually better place. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13546 --- diff --git a/coregrind/m_mallocfree.c b/coregrind/m_mallocfree.c index d9e10e25ff..013f89fafe 100644 --- a/coregrind/m_mallocfree.c +++ b/coregrind/m_mallocfree.c @@ -511,16 +511,6 @@ static ArenaId arenaP_to_ArenaId ( Arena *a ) return arena; } -SizeT VG_(malloc_effective_client_redzone_size)(void) -{ - vg_assert(VG_(needs).malloc_replacement); - ensure_mm_init (VG_AR_CLIENT); - /* ensure_mm_init will call arena_init if not yet done. - This then ensures that the arena redzone size is properly - initialised. */ - return arenaId_to_ArenaP(VG_AR_CLIENT)->rz_szB; -} - // Initialise an arena. rz_szB is the (default) minimum redzone size; // It might be overriden by VG_(clo_redzone_size) or VG_(clo_core_redzone_size). // it might be made bigger to ensure that VG_MIN_MALLOC_SZB is observed. @@ -2186,6 +2176,14 @@ void VG_(mallinfo) ( ThreadId tid, struct vg_mallinfo* mi ) mi->keepcost = 0; // may want some value in here } +SizeT VG_(arena_redzone_size) ( ArenaId aid ) +{ + ensure_mm_init (VG_AR_CLIENT); + /* ensure_mm_init will call arena_init if not yet done. + This then ensures that the arena redzone size is properly + initialised. */ + return arenaId_to_ArenaP(aid)->rz_szB; +} /*------------------------------------------------------------*/ /*--- Services layered on top of malloc/free. ---*/ diff --git a/coregrind/m_replacemalloc/replacemalloc_core.c b/coregrind/m_replacemalloc/replacemalloc_core.c index 773caef6d0..083164b7ec 100644 --- a/coregrind/m_replacemalloc/replacemalloc_core.c +++ b/coregrind/m_replacemalloc/replacemalloc_core.c @@ -31,6 +31,8 @@ #include "pub_core_basics.h" #include "pub_core_libcbase.h" #include "pub_core_libcprint.h" +#include "pub_core_libcassert.h" +#include "pub_core_tooliface.h" // VG_(needs) #include "pub_core_mallocfree.h" #include "pub_core_options.h" #include "pub_core_replacemalloc.h" @@ -71,6 +73,13 @@ Bool VG_(replacement_malloc_process_cmd_line_option)(const HChar* arg) return True; } +SizeT VG_(malloc_effective_client_redzone_size)(void) +{ + vg_assert(VG_(needs).malloc_replacement); + + return VG_(arena_redzone_size)(VG_AR_CLIENT); +} + /*------------------------------------------------------------*/ /*--- Useful functions ---*/ /*------------------------------------------------------------*/ diff --git a/coregrind/pub_core_mallocfree.h b/coregrind/pub_core_mallocfree.h index 834df471ff..bb163a77db 100644 --- a/coregrind/pub_core_mallocfree.h +++ b/coregrind/pub_core_mallocfree.h @@ -117,6 +117,8 @@ extern HChar* VG_(arena_strdup) ( ArenaId aid, const HChar* cc, extern SizeT VG_(arena_malloc_usable_size) ( ArenaId aid, void* payload ); +extern SizeT VG_(arena_redzone_size) ( ArenaId aid ); + extern void VG_(mallinfo) ( ThreadId tid, struct vg_mallinfo* mi ); // VG_(arena_perm_malloc) is for permanent allocation of small blocks. diff --git a/include/pub_tool_mallocfree.h b/include/pub_tool_mallocfree.h index 394eb8b37b..c6c37d1e40 100644 --- a/include/pub_tool_mallocfree.h +++ b/include/pub_tool_mallocfree.h @@ -47,15 +47,6 @@ extern HChar* VG_(strdup) ( const HChar* cc, const HChar* s ); // possibly some more due to rounding up. extern SizeT VG_(malloc_usable_size)( void* p ); - -// If tool is replacing malloc for the client, the below returns -// the effective client redzone as derived from the default -// provided by the tool, VG_(clo_redzone_size) and the minimum -// redzone required by m_mallocfree.c. -// It is an error to call this before VG_(needs_malloc_replacement) has -// been called. -extern SizeT VG_(malloc_effective_client_redzone_size)(void); - // TODO: move somewhere else // Call here to bomb the system when out of memory (mmap anon fails) __attribute__((noreturn)) diff --git a/include/pub_tool_replacemalloc.h b/include/pub_tool_replacemalloc.h index 97a9667186..a44e156236 100644 --- a/include/pub_tool_replacemalloc.h +++ b/include/pub_tool_replacemalloc.h @@ -65,6 +65,14 @@ extern UInt VG_(clo_alignment); extern Bool VG_(replacement_malloc_process_cmd_line_option) ( const HChar* arg ); +// If tool is replacing malloc for the client, the below returns +// the effective client redzone as derived from the default +// provided by the tool, VG_(clo_redzone_size) and the minimum +// redzone required by m_mallocfree.c. +// It is an error to call this before VG_(needs_malloc_replacement) has +// been called. +extern SizeT VG_(malloc_effective_client_redzone_size)(void); + #endif // __PUB_TOOL_REPLACEMALLOC_H /*--------------------------------------------------------------------*/