diff --git a/coregrind/amd64-linux/ldt.c b/coregrind/amd64-linux/ldt.c index 5b7c4637e..60977d657 100644 --- a/coregrind/amd64-linux/ldt.c +++ b/coregrind/amd64-linux/ldt.c @@ -110,8 +110,7 @@ VgLdtEntry* VG_(allocate_LDT_for_thread) ( VgLdtEntry* parent_ldt ) if (parent_ldt == NULL) { /* Allocate a new zeroed-out one. */ - ldt = (VgLdtEntry*)VG_(arena_calloc)(VG_AR_CORE, VG_MIN_MALLOC_SZB, - nbytes, 1); + ldt = (VgLdtEntry*)VG_(arena_calloc)(VG_AR_CORE, nbytes, 1); } else { ldt = (VgLdtEntry*)VG_(arena_malloc)(VG_AR_CORE, nbytes); for (i = 0; i < VG_M_LDT_ENTRIES; i++) diff --git a/coregrind/core.h b/coregrind/core.h index b506fca47..fc0ba65dc 100644 --- a/coregrind/core.h +++ b/coregrind/core.h @@ -387,10 +387,9 @@ typedef Int ArenaId; extern void* VG_(arena_malloc) ( ArenaId arena, SizeT nbytes ); extern void VG_(arena_free) ( ArenaId arena, void* ptr ); -extern void* VG_(arena_calloc) ( ArenaId arena, SizeT alignment, +extern void* VG_(arena_calloc) ( ArenaId arena, SizeT nmemb, SizeT bytes_per_memb ); -extern void* VG_(arena_realloc) ( ArenaId arena, void* ptr, SizeT alignment, - SizeT size ); +extern void* VG_(arena_realloc) ( ArenaId arena, void* ptr, SizeT size ); extern void* VG_(arena_malloc_aligned) ( ArenaId aid, SizeT req_alignB, SizeT req_pszB ); diff --git a/coregrind/demangle/cp-demangle.c b/coregrind/demangle/cp-demangle.c index 4bd37481f..7bd5d4c70 100644 --- a/coregrind/demangle/cp-demangle.c +++ b/coregrind/demangle/cp-demangle.c @@ -50,7 +50,7 @@ #define malloc(s) VG_(arena_malloc) (VG_AR_DEMANGLE, s) #define free(p) VG_(arena_free) (VG_AR_DEMANGLE, p) -#define realloc(p,s) VG_(arena_realloc)(VG_AR_DEMANGLE, p, VG_MIN_MALLOC_SZB, s) +#define realloc(p,s) VG_(arena_realloc)(VG_AR_DEMANGLE, p, s) #endif /* If CP_DEMANGLE_DEBUG is defined, a trace of the grammar evaluation, diff --git a/coregrind/demangle/cplus-dem.c b/coregrind/demangle/cplus-dem.c index 311b84fb9..98fd0c3ed 100644 --- a/coregrind/demangle/cplus-dem.c +++ b/coregrind/demangle/cplus-dem.c @@ -75,8 +75,7 @@ static char *ada_demangle PARAMS ((const char *, int)); #define xstrdup(ptr) VG_(arena_strdup) (VG_AR_DEMANGLE, ptr) #define free(ptr) VG_(arena_free) (VG_AR_DEMANGLE, ptr) #define xmalloc(size) VG_(arena_malloc) (VG_AR_DEMANGLE, size) -#define xrealloc(ptr, size) VG_(arena_realloc)(VG_AR_DEMANGLE, ptr, \ - VG_MIN_MALLOC_SZB, size) +#define xrealloc(ptr, size) VG_(arena_realloc)(VG_AR_DEMANGLE, ptr, size) #define abort() vg_assert(0) #undef strstr diff --git a/coregrind/demangle/dyn-string.c b/coregrind/demangle/dyn-string.c index 96a2f7dba..43a70ac48 100644 --- a/coregrind/demangle/dyn-string.c +++ b/coregrind/demangle/dyn-string.c @@ -38,7 +38,7 @@ Boston, MA 02111-1307, USA. */ #ifndef STANDALONE #define malloc(s) VG_(arena_malloc) (VG_AR_DEMANGLE, s) #define free(p) VG_(arena_free) (VG_AR_DEMANGLE, p) -#define realloc(p,s) VG_(arena_realloc)(VG_AR_DEMANGLE, p, VG_MIN_MALLOC_SZB, s) +#define realloc(p,s) VG_(arena_realloc)(VG_AR_DEMANGLE, p, s) #endif /* If this file is being compiled for inclusion in the C++ runtime diff --git a/coregrind/vg_dwarf.c b/coregrind/vg_dwarf.c index de656f366..120cbf79c 100644 --- a/coregrind/vg_dwarf.c +++ b/coregrind/vg_dwarf.c @@ -217,9 +217,8 @@ int process_extended_line_op( SegInfo *si, Char*** fnames, *fnames = VG_(arena_malloc)(VG_AR_SYMTAB, sizeof (UInt) * 2); else *fnames = VG_(arena_realloc)( - VG_AR_SYMTAB, *fnames, VG_MIN_MALLOC_SZB, - sizeof(UInt) - * (state_machine_regs.last_file_entry + 1)); + VG_AR_SYMTAB, *fnames, + sizeof(UInt) * (state_machine_regs.last_file_entry + 1)); (*fnames)[state_machine_regs.last_file_entry] = VG_(addStr) (si,name, -1); data += VG_(strlen) ((char *) data) + 1; read_leb128 (data, & bytes_read, 0); @@ -370,7 +369,6 @@ void VG_(read_debuginfo_dwarf2) ( SegInfo* si, UChar* dwarf2, Int dwarf2_sz ) fnames = VG_(arena_malloc)(VG_AR_SYMTAB, sizeof (UInt) * 2); else fnames = VG_(arena_realloc)(VG_AR_SYMTAB, fnames, - VG_MIN_MALLOC_SZB, sizeof(UInt) * (state_machine_regs.last_file_entry + 1)); data += VG_(strlen) ((Char *) data) + 1; diff --git a/coregrind/vg_malloc2.c b/coregrind/vg_malloc2.c index 62dfe496b..f0314162a 100644 --- a/coregrind/vg_malloc2.c +++ b/coregrind/vg_malloc2.c @@ -1251,8 +1251,7 @@ SizeT VG_(arena_payload_szB) ( ArenaId aid, void* ptr ) /*--- Services layered on top of malloc/free. ---*/ /*------------------------------------------------------------*/ -void* VG_(arena_calloc) ( ArenaId aid, SizeT alignB, SizeT nmemb, - SizeT bytes_per_memb ) +void* VG_(arena_calloc) ( ArenaId aid, SizeT nmemb, SizeT bytes_per_memb ) { SizeT size; UChar* p; @@ -1262,10 +1261,7 @@ void* VG_(arena_calloc) ( ArenaId aid, SizeT alignB, SizeT nmemb, size = nmemb * bytes_per_memb; vg_assert(size >= nmemb && size >= bytes_per_memb);// check against overflow - if (alignB == VG_MIN_MALLOC_SZB) - p = VG_(arena_malloc) ( aid, size ); - else - p = VG_(arena_malloc_aligned) ( aid, alignB, size ); + p = VG_(arena_malloc) ( aid, size ); VG_(memset)(p, 0, size); @@ -1277,8 +1273,7 @@ void* VG_(arena_calloc) ( ArenaId aid, SizeT alignB, SizeT nmemb, } -void* VG_(arena_realloc) ( ArenaId aid, void* ptr, - SizeT req_alignB, SizeT req_pszB ) +void* VG_(arena_realloc) ( ArenaId aid, void* ptr, SizeT req_pszB ) { Arena* a; SizeT old_bszB, old_pszB; @@ -1305,12 +1300,8 @@ void* VG_(arena_realloc) ( ArenaId aid, void* ptr, return ptr; } - if (req_alignB == VG_MIN_MALLOC_SZB) - p_new = VG_(arena_malloc) ( aid, req_pszB ); - else { - p_new = VG_(arena_malloc_aligned) ( aid, req_alignB, req_pszB ); - } - + p_new = VG_(arena_malloc) ( aid, req_pszB ); + VG_(memcpy)(p_new, ptr, old_pszB); VG_(arena_free)(aid, ptr); @@ -1338,13 +1329,12 @@ void VG_(free) ( void* ptr ) void* VG_(calloc) ( SizeT nmemb, SizeT bytes_per_memb ) { - return VG_(arena_calloc) ( VG_AR_TOOL, VG_MIN_MALLOC_SZB, nmemb, - bytes_per_memb ); + return VG_(arena_calloc) ( VG_AR_TOOL, nmemb, bytes_per_memb ); } void* VG_(realloc) ( void* ptr, SizeT size ) { - return VG_(arena_realloc) ( VG_AR_TOOL, ptr, VG_MIN_MALLOC_SZB, size ); + return VG_(arena_realloc) ( VG_AR_TOOL, ptr, size ); } void* VG_(malloc_aligned) ( SizeT req_alignB, SizeT req_pszB ) diff --git a/coregrind/x86/state.c b/coregrind/x86/state.c index 8d73517df..d7d9ba880 100644 --- a/coregrind/x86/state.c +++ b/coregrind/x86/state.c @@ -192,20 +192,16 @@ void VGA_(init_thread1state) ( Addr client_eip, VexGuestX86SegDescr* VG_(alloc_zeroed_x86_GDT) ( void ) { - Int nbytes - = VEX_GUEST_X86_GDT_NENT * sizeof(VexGuestX86SegDescr); - return - VG_(arena_calloc)(VG_AR_CORE, VG_MIN_MALLOC_SZB, nbytes, 1); + Int nbytes = VEX_GUEST_X86_GDT_NENT * sizeof(VexGuestX86SegDescr); + return VG_(arena_calloc)(VG_AR_CORE, nbytes, 1); } /* Create a zeroed-out LDT. */ VexGuestX86SegDescr* VG_(alloc_zeroed_x86_LDT) ( void ) { - Int nbytes - = VEX_GUEST_X86_LDT_NENT * sizeof(VexGuestX86SegDescr); - return - VG_(arena_calloc)(VG_AR_CORE, VG_MIN_MALLOC_SZB, nbytes, 1); + Int nbytes = VEX_GUEST_X86_LDT_NENT * sizeof(VexGuestX86SegDescr); + return VG_(arena_calloc)(VG_AR_CORE, nbytes, 1); } /* Free up an LDT or GDT allocated by the above fns. */