Implemented malloc_usable_size(), which was used in a program written by
Frederic Delley <fdelley@cisco.com>.

This required also adding VG_(arena_payload_szB)().


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1540 a5019735-40e9-0310-863c-91ae7b9d1cf9
diff --git a/coregrind/vg_replace_malloc.c b/coregrind/vg_replace_malloc.c
index 42e2e11..2299fad 100644
--- a/coregrind/vg_replace_malloc.c
+++ b/coregrind/vg_replace_malloc.c
@@ -362,6 +362,26 @@
     return VKI_ENOMEM /*12*/ /*ENOMEM*/;
 }
 
+Int malloc_usable_size ( void* p )
+{ 
+   Int pszB;
+   
+   MALLOC_TRACE("malloc_usable_size[simd=%d](%p)", 
+                (UInt)VG_(is_running_on_simd_CPU)(), p );
+   if (NULL == p)
+      return 0;
+
+   if (VG_(is_running_on_simd_CPU)()) {
+      pszB = (Int)VALGRIND_NON_SIMD_CALL2( VG_(arena_payload_szB), 
+                                           VG_AR_CLIENT, p );
+   } else {
+      pszB = VG_(arena_payload_szB)(VG_AR_CLIENT, p);
+   }
+   MALLOC_TRACE(" = %d\n", pszB );
+
+   return pszB;
+}
+
 
 /* Bomb out if we get any of these. */
 /* HACK: We shouldn't call VG_(core_panic) or VG_(message) on the simulated
@@ -372,8 +392,7 @@
 { VG_(core_panic)("call to pvalloc\n"); }
 void malloc_stats ( void )
 { VG_(core_panic)("call to malloc_stats\n"); }
-void malloc_usable_size ( void )
-{ VG_(core_panic)("call to malloc_usable_size\n"); }
+
 void malloc_trim ( void )
 { VG_(core_panic)("call to malloc_trim\n"); }
 void malloc_get_state ( void )