mirror of
https://github.com/Zenithsiz/ftmemsim-valgrind.git
synced 2026-02-08 04:55:52 +00:00
Remove the alignment arg from VG_(arena_calloc)() and VG_(arena_realloc)(),
because it was always being set to VG_MIN_ALLOC_SZB, and so was just one more thing to get wrong, as well as exposing VG_MIN_ALLOC_SZB to more places than necessary. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3340
This commit is contained in:
parent
122ce0fcb5
commit
ba91df6db8
@ -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++)
|
||||
|
||||
@ -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 );
|
||||
|
||||
|
||||
@ -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,
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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 )
|
||||
|
||||
@ -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. */
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user