aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorflorian <florian@a5019735-40e9-0310-863c-91ae7b9d1cf9>2013-09-15 09:18:03 +0000
committerflorian <florian@a5019735-40e9-0310-863c-91ae7b9d1cf9>2013-09-15 09:18:03 +0000
commitac3a1d8cbe5d509107e4dfaa56900c0ff825bf45 (patch)
treef068460b7c30c6fe8f08ff28faeefbc12b3a9a13
parent9b705b9fc6061660af72e10d684ad50df0bbbe9b (diff)
downloadvalgrind-ac3a1d8cbe5d509107e4dfaa56900c0ff825bf45.tar.gz
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 a5019735-40e9-0310-863c-91ae7b9d1cf9
-rw-r--r--coregrind/m_mallocfree.c18
-rw-r--r--coregrind/m_replacemalloc/replacemalloc_core.c9
-rw-r--r--coregrind/pub_core_mallocfree.h2
-rw-r--r--include/pub_tool_mallocfree.h9
-rw-r--r--include/pub_tool_replacemalloc.h8
5 files changed, 27 insertions, 19 deletions
diff --git a/coregrind/m_mallocfree.c b/coregrind/m_mallocfree.c
index d9e10e25f..013f89faf 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 773caef6d..083164b7e 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 834df471f..bb163a77d 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 394eb8b37..c6c37d1e4 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 97a966718..a44e15623 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
/*--------------------------------------------------------------------*/