while ((n % 4) > 0) n++; \
}
-/* ALL calls to malloc wind up here. */
-void* malloc ( Int n )
-{
- void* v;
-
- MALLOC_TRACE("malloc[simd=%d](%d)",
- (UInt)VG_(is_running_on_simd_CPU)(), n );
- MAYBE_SLOPPIFY(n);
-
- if (VG_(is_running_on_simd_CPU)()) {
- v = (void*)VALGRIND_NON_SIMD_CALL1( SK_(malloc), n );
- } else if (VG_(clo_alignment) != 4) {
- v = VG_(arena_malloc_aligned)(VG_AR_CLIENT, VG_(clo_alignment), n);
- } else {
- v = VG_(arena_malloc)(VG_AR_CLIENT, n);
- }
- MALLOC_TRACE(" = %p\n", v );
- return v;
-}
-
-void* __builtin_new ( Int n )
-{
- void* v;
-
- MALLOC_TRACE("__builtin_new[simd=%d](%d)",
- (UInt)VG_(is_running_on_simd_CPU)(), n );
- MAYBE_SLOPPIFY(n);
-
- if (VG_(is_running_on_simd_CPU)()) {
- v = (void*)VALGRIND_NON_SIMD_CALL1( SK_(__builtin_new), n );
- } else if (VG_(clo_alignment) != 4) {
- v = VG_(arena_malloc_aligned)(VG_AR_CLIENT, VG_(clo_alignment), n);
- } else {
- v = VG_(arena_malloc)(VG_AR_CLIENT, n);
- }
- MALLOC_TRACE(" = %p\n", v );
- return v;
-}
-
-/* gcc 3.X.X mangles them differently. */
-void* _Znwj ( Int n )
-{
- return __builtin_new(n);
-}
-
-void* __builtin_vec_new ( Int n )
-{
- void* v;
-
- MALLOC_TRACE("__builtin_vec_new[simd=%d](%d)",
- (UInt)VG_(is_running_on_simd_CPU)(), n );
- MAYBE_SLOPPIFY(n);
-
- if (VG_(is_running_on_simd_CPU)()) {
- v = (void*)VALGRIND_NON_SIMD_CALL1( SK_(__builtin_vec_new), n );
- } else if (VG_(clo_alignment) != 4) {
- v = VG_(arena_malloc_aligned)(VG_AR_CLIENT, VG_(clo_alignment), n);
- } else {
- v = VG_(arena_malloc)(VG_AR_CLIENT, n);
- }
- MALLOC_TRACE(" = %p\n", v );
- return v;
+/* ALL calls to malloc() and friends wind up here. */
+#define ALLOC(fff, vgfff) \
+void* fff ( Int n ) \
+{ \
+ void* v; \
+ \
+ MALLOC_TRACE(#fff "[simd=%d](%d)", \
+ (UInt)VG_(is_running_on_simd_CPU)(), n ); \
+ MAYBE_SLOPPIFY(n); \
+ \
+ if (VG_(is_running_on_simd_CPU)()) { \
+ v = (void*)VALGRIND_NON_SIMD_CALL1( vgfff, n ); \
+ } else if (VG_(clo_alignment) != 4) { \
+ v = VG_(arena_malloc_aligned)(VG_AR_CLIENT, VG_(clo_alignment), n); \
+ } else { \
+ v = VG_(arena_malloc)(VG_AR_CLIENT, n); \
+ } \
+ MALLOC_TRACE(" = %p\n", v ); \
+ return v; \
}
-
-/* gcc 3.X.X mangles them differently. */
-void* _Znaj ( Int n )
-{
- return __builtin_vec_new(n);
-}
-
-void free ( void* p )
-{
- MALLOC_TRACE("free[simd=%d](%p)\n",
- (UInt)VG_(is_running_on_simd_CPU)(), p );
- if (p == NULL)
- return;
- if (VG_(is_running_on_simd_CPU)()) {
- (void)VALGRIND_NON_SIMD_CALL1( SK_(free), p );
- } else {
- VG_(arena_free)(VG_AR_CLIENT, p);
- }
-}
-
-void __builtin_delete ( void* p )
-{
- MALLOC_TRACE("__builtin_delete[simd=%d](%p)\n",
- (UInt)VG_(is_running_on_simd_CPU)(), p );
- if (p == NULL)
- return;
- if (VG_(is_running_on_simd_CPU)()) {
- (void)VALGRIND_NON_SIMD_CALL1( SK_(__builtin_delete), p );
- } else {
- VG_(arena_free)(VG_AR_CLIENT, p);
- }
-}
-
-/* gcc 3.X.X mangles them differently. */
-void _ZdlPv ( void* p )
-{
- __builtin_delete(p);
-}
-
-void __builtin_vec_delete ( void* p )
-{
- MALLOC_TRACE("__builtin_vec_delete[simd=%d](%p)\n",
- (UInt)VG_(is_running_on_simd_CPU)(), p );
- if (p == NULL)
- return;
- if (VG_(is_running_on_simd_CPU)()) {
- (void)VALGRIND_NON_SIMD_CALL1( SK_(__builtin_vec_delete), p );
- } else {
- VG_(arena_free)(VG_AR_CLIENT, p);
- }
-}
-
-/* gcc 3.X.X mangles them differently. */
-void _ZdaPv ( void* p )
-{
- __builtin_vec_delete(p);
+ALLOC( malloc, SK_(malloc) );
+ALLOC( __builtin_new, SK_(__builtin_new) );
+ALLOC( _Znwj, SK_(__builtin_new) );
+ALLOC( __builtin_vec_new, SK_(__builtin_vec_new) );
+ALLOC( _Znaj, SK_(__builtin_vec_new) );
+
+#define FREE(fff, vgfff) \
+void fff ( void* p ) \
+{ \
+ MALLOC_TRACE(#fff "[simd=%d](%p)\n", \
+ (UInt)VG_(is_running_on_simd_CPU)(), p ); \
+ if (p == NULL) \
+ return; \
+ if (VG_(is_running_on_simd_CPU)()) { \
+ (void)VALGRIND_NON_SIMD_CALL1( vgfff, p ); \
+ } else { \
+ VG_(arena_free)(VG_AR_CLIENT, p); \
+ } \
}
+FREE( free, SK_(free) );
+FREE( __builtin_delete, SK_(__builtin_delete) );
+FREE( _ZdlPv, SK_(__builtin_delete) );
+FREE( __builtin_vec_delete, SK_(__builtin_vec_delete) );
+FREE( _ZdaPv, SK_(__builtin_vec_delete) );
void* calloc ( UInt nmemb, UInt size )
{
Mismatched free() / delete / delete []
- at 0x........: __builtin_delete (vg_replace_malloc.c:...)
+ at 0x........: operator delete(void*) (vg_replace_malloc.c:...)
by 0x........: main (mismatches.cpp:6)
by 0x........: __libc_start_main (...libc...)
+ by 0x........: ...
Address 0x........ is 0 bytes inside a block of size 10 alloc'd
at 0x........: malloc (vg_replace_malloc.c:...)
by 0x........: main (mismatches.cpp:5)
by 0x........: __libc_start_main (...libc...)
+ by 0x........: ...
Mismatched free() / delete / delete []
- at 0x........: __builtin_vec_delete (vg_replace_malloc.c:...)
+ at 0x........: operator delete[](void*) (vg_replace_malloc.c:...)
by 0x........: main (mismatches.cpp:8)
by 0x........: __libc_start_main (...libc...)
+ by 0x........: ...
Address 0x........ is 0 bytes inside a block of size 10 alloc'd
at 0x........: malloc (vg_replace_malloc.c:...)
by 0x........: main (mismatches.cpp:7)
by 0x........: __libc_start_main (...libc...)
+ by 0x........: ...
Mismatched free() / delete / delete []
- at 0x........: __builtin_delete (vg_replace_malloc.c:...)
+ at 0x........: operator delete(void*) (vg_replace_malloc.c:...)
by 0x........: main (mismatches.cpp:13)
by 0x........: __libc_start_main (...libc...)
+ by 0x........: ...
Address 0x........ is 0 bytes inside a block of size 40 alloc'd
- at 0x........: __builtin_vec_new (vg_replace_malloc.c:...)
+ at 0x........: operator new[](unsigned) (vg_replace_malloc.c:...)
by 0x........: main (mismatches.cpp:12)
by 0x........: __libc_start_main (...libc...)
+ by 0x........: ...
Mismatched free() / delete / delete []
at 0x........: free (vg_replace_malloc.c:...)
by 0x........: main (mismatches.cpp:15)
by 0x........: __libc_start_main (...libc...)
+ by 0x........: ...
Address 0x........ is 0 bytes inside a block of size 40 alloc'd
- at 0x........: __builtin_vec_new (vg_replace_malloc.c:...)
+ at 0x........: operator new[](unsigned) (vg_replace_malloc.c:...)
by 0x........: main (mismatches.cpp:14)
by 0x........: __libc_start_main (...libc...)
+ by 0x........: ...
Mismatched free() / delete / delete []
- at 0x........: __builtin_vec_delete (vg_replace_malloc.c:...)
+ at 0x........: operator delete[](void*) (vg_replace_malloc.c:...)
by 0x........: main (mismatches.cpp:20)
by 0x........: __libc_start_main (...libc...)
+ by 0x........: ...
Address 0x........ is 0 bytes inside a block of size 4 alloc'd
- at 0x........: __builtin_new (vg_replace_malloc.c:...)
+ at 0x........: operator new(unsigned) (vg_replace_malloc.c:...)
by 0x........: main (mismatches.cpp:19)
by 0x........: __libc_start_main (...libc...)
+ by 0x........: ...
Mismatched free() / delete / delete []
at 0x........: free (vg_replace_malloc.c:...)
by 0x........: main (mismatches.cpp:22)
by 0x........: __libc_start_main (...libc...)
+ by 0x........: ...
Address 0x........ is 0 bytes inside a block of size 4 alloc'd
- at 0x........: __builtin_new (vg_replace_malloc.c:...)
+ at 0x........: operator new(unsigned) (vg_replace_malloc.c:...)
by 0x........: main (mismatches.cpp:21)
by 0x........: __libc_start_main (...libc...)
+ by 0x........: ...