From: Florian Krohm Date: Thu, 11 Sep 2014 21:19:17 +0000 (+0000) Subject: Use wrapper functions VG_(malloc) and friends consistently across the X-Git-Tag: svn/VALGRIND_3_11_0~1013 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3b95ad549a48338f7a21d0a4b973d195e97743d8;p=thirdparty%2Fvalgrind.git Use wrapper functions VG_(malloc) and friends consistently across the board (instead of e.g. VG_(arena_malloc)(VG_AR_CORE,...). This change also benefits static analysers. We can tell tools that VG_(malloc) allocates and VG_(free) deallocates and that they are a pair. But we cannot do that for arena_malloc/free. Also provide a wrapper VG_(realloc_shrink). git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14517 --- diff --git a/coregrind/m_coredump/coredump-elf.c b/coregrind/m_coredump/coredump-elf.c index 61a1ce04d8..9be2c5374c 100644 --- a/coregrind/m_coredump/coredump-elf.c +++ b/coregrind/m_coredump/coredump-elf.c @@ -169,7 +169,7 @@ static void add_note(struct note **list, const HChar *name, UInt type, Int notelen = sizeof(struct note) + VG_ROUNDUP(namelen, 4) + VG_ROUNDUP(datasz, 4); - struct note *n = VG_(arena_malloc)(VG_AR_CORE, "coredump-elf.an.1", notelen); + struct note *n = VG_(malloc)("coredump-elf.an.1", notelen); VG_(memset)(n, 0, notelen); @@ -648,8 +648,7 @@ void make_elf_coredump(ThreadId tid, const vki_siginfo_t *si, ULong max_size) notelist = NULL; /* Second, work out their layout */ - phdrs = VG_(arena_malloc)(VG_AR_CORE, "coredump-elf.mec.1", - sizeof(*phdrs) * num_phdrs); + phdrs = VG_(malloc)("coredump-elf.mec.1", sizeof(*phdrs) * num_phdrs); /* Add details for all threads except the one that faulted */ for(i = 1; i < VG_N_THREADS; i++) { diff --git a/coregrind/m_errormgr.c b/coregrind/m_errormgr.c index f1dd861bca..e08cfc879a 100644 --- a/coregrind/m_errormgr.c +++ b/coregrind/m_errormgr.c @@ -824,7 +824,7 @@ void VG_(maybe_record_error) ( ThreadId tid, DedupPoolAlloc for these strings will avoid duplicating such string in each error using it. */ if (NULL != p->string) { - p->string = VG_(arena_strdup)(VG_AR_CORE, "errormgr.mre.2", p->string); + p->string = VG_(strdup)("errormgr.mre.2", p->string); } /* copy block pointed to by 'extra', if there is one */ @@ -1198,15 +1198,13 @@ static Bool is_simple_str (const HChar *s) static Bool setLocationTy ( SuppLoc* p, HChar *buf ) { if (VG_(strncmp)(buf, "fun:", 4) == 0) { - p->name = VG_(arena_strdup)(VG_AR_CORE, - "errormgr.sLTy.1", buf+4); + p->name = VG_(strdup)("errormgr.sLTy.1", buf+4); p->name_is_simple_str = is_simple_str (p->name); p->ty = FunName; return True; } if (VG_(strncmp)(buf, "obj:", 4) == 0) { - p->name = VG_(arena_strdup)(VG_AR_CORE, - "errormgr.sLTy.2", buf+4); + p->name = VG_(strdup)("errormgr.sLTy.2", buf+4); p->name_is_simple_str = is_simple_str (p->name); p->ty = ObjName; return True; @@ -1280,8 +1278,7 @@ static void load_one_suppressions_file ( Int clo_suppressions_i ) while (True) { /* Assign and initialise the two suppression halves (core and tool) */ Supp* supp; - supp = VG_(arena_malloc)(VG_AR_CORE, "errormgr.losf.1", - sizeof(Supp)); + supp = VG_(malloc)("errormgr.losf.1", sizeof(Supp)); supp->count = 0; // Initialise temporary reading-in buffer. @@ -1295,7 +1292,7 @@ static void load_one_suppressions_file ( Int clo_suppressions_i ) eof = get_nbnc_line ( fd, &buf, &nBuf, &lineno ); if (eof) { - VG_(arena_free)(VG_AR_CORE, supp); + VG_(free)(supp); break; } @@ -1305,7 +1302,7 @@ static void load_one_suppressions_file ( Int clo_suppressions_i ) if (eof || VG_STREQ(buf, "}")) BOMB("unexpected '}'"); - supp->sname = VG_(arena_strdup)(VG_AR_CORE, "errormgr.losf.2", buf); + supp->sname = VG_(strdup)("errormgr.losf.2", buf); supp->clo_suppressions_i = clo_suppressions_i; supp->sname_lineno = lineno; @@ -1352,8 +1349,8 @@ static void load_one_suppressions_file ( Int clo_suppressions_i ) if (VG_STREQ(buf, "}")) break; } - VG_(arena_free)(VG_AR_CORE, supp->sname); - VG_(arena_free)(VG_AR_CORE, supp); + VG_(free)(supp->sname); + VG_(free)(supp); continue; } @@ -1422,8 +1419,7 @@ static void load_one_suppressions_file ( Int clo_suppressions_i ) // Copy tmp_callers[] into supp->callers[] supp->n_callers = i; - supp->callers = VG_(arena_malloc)(VG_AR_CORE, "errormgr.losf.4", - i*sizeof(SuppLoc)); + supp->callers = VG_(malloc)("errormgr.losf.4", i * sizeof(SuppLoc)); for (i = 0; i < supp->n_callers; i++) { supp->callers[i] = tmp_callers[i]; } diff --git a/coregrind/m_gdbserver/m_gdbserver.c b/coregrind/m_gdbserver/m_gdbserver.c index be94234624..04ca77c9af 100644 --- a/coregrind/m_gdbserver/m_gdbserver.c +++ b/coregrind/m_gdbserver/m_gdbserver.c @@ -161,13 +161,11 @@ static int gdbserver_exited = 0; /* alloc and free functions for xarray and similar. */ static void* gs_alloc (const HChar* cc, SizeT sz) { - void* res = VG_(arena_malloc)(VG_AR_CORE, cc, sz); - vg_assert (res); - return res; + return VG_(malloc)(cc, sz); } static void gs_free (void* ptr) { - VG_(arena_free)(VG_AR_CORE, ptr); + VG_(free)(ptr); } typedef @@ -213,7 +211,7 @@ static void add_gs_address (Addr addr, GS_Kind kind, const HChar* from) { GS_Address *p; - p = VG_(arena_malloc)(VG_AR_CORE, from, sizeof(GS_Address)); + p = VG_(malloc)(from, sizeof(GS_Address)); p->addr = HT_addr (addr); p->kind = kind; VG_(HT_add_node)(gs_addresses, p); @@ -232,7 +230,7 @@ static void remove_gs_address (GS_Address* g, const HChar* from) // See add_gs_address for the explanation for condition and the range 2 below. if (VG_(clo_vgdb) != Vg_VgdbFull) VG_(discard_translations) (g->addr, 2, from); - VG_(arena_free) (VG_AR_CORE, g); + VG_(free) (g); } const HChar* VG_(ppPointKind) (PointKind kind) @@ -374,8 +372,7 @@ Bool VG_(gdbserver_point) (PointKind kind, Bool insert, g = lookup_gs_watch (addr, len, kind, &g_ix); if (insert) { if (g == NULL) { - g = VG_(arena_malloc)(VG_AR_CORE, "gdbserver_point watchpoint", - sizeof(GS_Watch)); + g = VG_(malloc)("gdbserver_point watchpoint", sizeof(GS_Watch)); g->addr = addr; g->len = len; g->kind = kind; @@ -388,7 +385,7 @@ Bool VG_(gdbserver_point) (PointKind kind, Bool insert, } else { if (g != NULL) { VG_(removeIndexXA) (gs_watches, g_ix); - VG_(arena_free) (VG_AR_CORE, g); + VG_(free) (g); } else { dlog(1, "VG_(gdbserver_point) addr %p len %d kind %s already deleted?\n", diff --git a/coregrind/m_gdbserver/server.h b/coregrind/m_gdbserver/server.h index ca016e98ca..39e42a246a 100644 --- a/coregrind/m_gdbserver/server.h +++ b/coregrind/m_gdbserver/server.h @@ -156,11 +156,11 @@ extern ThreadId vgdb_interrupted_tid; VG_(strtoull16) ((s),(r)) \ : VG_(strtoull10) ((s),(r))) -#define malloc(sz) VG_(arena_malloc) (VG_AR_CORE, "gdbsrv", sz) -#define calloc(n,sz) VG_(arena_calloc) (VG_AR_CORE, "gdbsrv", n, sz) -#define realloc(p,size) VG_(arena_realloc) (VG_AR_CORE, "gdbsrv", p, size) -#define strdup(s) VG_(arena_strdup) (VG_AR_CORE, "gdbsrv", (s)) -#define free(b) VG_(arena_free) (VG_AR_CORE, b) +#define malloc(sz) VG_(malloc) ("gdbsrv", sz) +#define calloc(n,sz) VG_(calloc) ("gdbsrv", n, sz) +#define realloc(p,size) VG_(realloc) ("gdbsrv", p, size) +#define strdup(s) VG_(strdup) ("gdbsrv", (s)) +#define free(b) VG_(free) (b) #ifndef ATTR_NORETURN #if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7)) diff --git a/coregrind/m_libcproc.c b/coregrind/m_libcproc.c index b3580fc689..98c625f1de 100644 --- a/coregrind/m_libcproc.c +++ b/coregrind/m_libcproc.c @@ -114,8 +114,7 @@ HChar **VG_(env_setenv) ( HChar ***envp, const HChar* varname, HChar **env = (*envp); HChar **cpp; Int len = VG_(strlen)(varname); - HChar *valstr = VG_(arena_malloc)(VG_AR_CORE, "libcproc.es.1", - len + VG_(strlen)(val) + 2); + HChar *valstr = VG_(malloc)("libcproc.es.1", len + VG_(strlen)(val) + 2); HChar **oldenv = NULL; VG_(sprintf)(valstr, "%s=%s", varname, val); @@ -128,7 +127,7 @@ HChar **VG_(env_setenv) ( HChar ***envp, const HChar* varname, } if (env == NULL) { - env = VG_(arena_malloc)(VG_AR_CORE, "libcproc.es.2", sizeof(HChar *) * 2); + env = VG_(malloc)("libcproc.es.2", sizeof(HChar *) * 2); env[0] = valstr; env[1] = NULL; @@ -136,8 +135,7 @@ HChar **VG_(env_setenv) ( HChar ***envp, const HChar* varname, } else { Int envlen = (cpp-env) + 2; - HChar **newenv = VG_(arena_malloc)(VG_AR_CORE, "libcproc.es.3", - envlen * sizeof(HChar *)); + HChar **newenv = VG_(malloc)("libcproc.es.3", envlen * sizeof(HChar *)); for (cpp = newenv; *env; ) *cpp++ = *env++; @@ -243,21 +241,20 @@ void VG_(env_remove_valgrind_env_stuff)(HChar** envp) // - DYLD_INSERT_LIBRARIES and DYLD_SHARED_REGION are Darwin-only for (i = 0; envp[i] != NULL; i++) { if (VG_(strncmp)(envp[i], "LD_PRELOAD=", 11) == 0) { - envp[i] = VG_(arena_strdup)(VG_AR_CORE, "libcproc.erves.1", envp[i]); + envp[i] = VG_(strdup)("libcproc.erves.1", envp[i]); ld_preload_str = &envp[i][11]; } if (VG_(strncmp)(envp[i], "LD_LIBRARY_PATH=", 16) == 0) { - envp[i] = VG_(arena_strdup)(VG_AR_CORE, "libcproc.erves.2", envp[i]); + envp[i] = VG_(strdup)("libcproc.erves.2", envp[i]); ld_library_path_str = &envp[i][16]; } if (VG_(strncmp)(envp[i], "DYLD_INSERT_LIBRARIES=", 22) == 0) { - envp[i] = VG_(arena_strdup)(VG_AR_CORE, "libcproc.erves.3", envp[i]); + envp[i] = VG_(strdup)("libcproc.erves.3", envp[i]); dyld_insert_libraries_str = &envp[i][22]; } } - buf = VG_(arena_malloc)(VG_AR_CORE, "libcproc.erves.4", - VG_(strlen)(VG_(libdir)) + 20); + buf = VG_(malloc)("libcproc.erves.4", VG_(strlen)(VG_(libdir)) + 20); // Remove Valgrind-specific entries from LD_*. VG_(sprintf)(buf, "%s*/vgpreload_*.so", VG_(libdir)); @@ -274,7 +271,7 @@ void VG_(env_remove_valgrind_env_stuff)(HChar** envp) // XXX if variable becomes empty, remove it completely? - VG_(arena_free)(VG_AR_CORE, buf); + VG_(free)(buf); } /* --------------------------------------------------------------------- @@ -309,8 +306,7 @@ HChar **VG_(env_clone) ( HChar **oldenv ) envlen = oldenvp - oldenv + 1; - newenv = VG_(arena_malloc)(VG_AR_CORE, "libcproc.ec.1", - envlen * sizeof(HChar *)); + newenv = VG_(malloc)("libcproc.ec.1", envlen * sizeof(HChar *)); oldenvp = oldenv; newenvp = newenv; diff --git a/coregrind/m_main.c b/coregrind/m_main.c index b3035c78cb..743aad6d14 100644 --- a/coregrind/m_main.c +++ b/coregrind/m_main.c @@ -1146,7 +1146,7 @@ void main_process_cmd_line_options ( /*OUT*/Bool* logging_to_fd, the default one. */ static const HChar default_supp[] = "default.supp"; Int len = VG_(strlen)(VG_(libdir)) + 1 + sizeof(default_supp); - HChar *buf = VG_(arena_malloc)(VG_AR_CORE, "main.mpclo.3", len); + HChar *buf = VG_(malloc)("main.mpclo.3", len); VG_(sprintf)(buf, "%s/%s", VG_(libdir), default_supp); VG_(clo_suppressions)[VG_(clo_n_suppressions)] = buf; VG_(clo_n_suppressions)++; diff --git a/coregrind/m_mallocfree.c b/coregrind/m_mallocfree.c index 93b7a2a4a4..9e42c25403 100644 --- a/coregrind/m_mallocfree.c +++ b/coregrind/m_mallocfree.c @@ -2594,6 +2594,11 @@ void* VG_(realloc) ( const HChar* cc, void* ptr, SizeT size ) return VG_(arena_realloc) ( VG_AR_CORE, cc, ptr, size ); } +void VG_(realloc_shrink) ( void* ptr, SizeT size ) +{ + VG_(arena_realloc_shrink) ( VG_AR_CORE, ptr, size ); +} + HChar* VG_(strdup) ( const HChar* cc, const HChar* s ) { return VG_(arena_strdup) ( VG_AR_CORE, cc, s ); diff --git a/coregrind/m_scheduler/scheduler.c b/coregrind/m_scheduler/scheduler.c index effd0cedaf..14d340ae0d 100644 --- a/coregrind/m_scheduler/scheduler.c +++ b/coregrind/m_scheduler/scheduler.c @@ -242,7 +242,7 @@ ThreadId VG_(alloc_ThreadState) ( void ) VG_(threads)[i].status = VgTs_Init; VG_(threads)[i].exitreason = VgSrc_None; if (VG_(threads)[i].thread_name) - VG_(arena_free)(VG_AR_CORE, VG_(threads)[i].thread_name); + VG_(free)(VG_(threads)[i].thread_name); VG_(threads)[i].thread_name = NULL; return i; } diff --git a/coregrind/m_signals.c b/coregrind/m_signals.c index 6ce03f8899..77c1c8da00 100644 --- a/coregrind/m_signals.c +++ b/coregrind/m_signals.c @@ -1328,7 +1328,7 @@ void VG_(clear_out_queued_signals)( ThreadId tid, vki_sigset_t* saved_mask ) { block_all_host_signals(saved_mask); if (VG_(threads)[tid].sig_queue != NULL) { - VG_(arena_free)(VG_AR_CORE, VG_(threads)[tid].sig_queue); + VG_(free)(VG_(threads)[tid].sig_queue); VG_(threads)[tid].sig_queue = NULL; } restore_all_host_signals(saved_mask); @@ -2052,8 +2052,7 @@ void queue_signal(ThreadId tid, const vki_siginfo_t *si) block_all_host_signals(&savedmask); if (tst->sig_queue == NULL) { - tst->sig_queue = VG_(arena_malloc)(VG_AR_CORE, "signals.qs.1", - sizeof(*tst->sig_queue)); + tst->sig_queue = VG_(malloc)("signals.qs.1", sizeof(*tst->sig_queue)); VG_(memset)(tst->sig_queue, 0, sizeof(*tst->sig_queue)); } sq = tst->sig_queue; diff --git a/coregrind/m_stacks.c b/coregrind/m_stacks.c index d1165476a9..43fd6bab45 100644 --- a/coregrind/m_stacks.c +++ b/coregrind/m_stacks.c @@ -191,7 +191,7 @@ UWord VG_(register_stack)(Addr start, Addr end) start = t; } - i = (Stack *)VG_(arena_malloc)(VG_AR_CORE, "stacks.rs.1", sizeof(Stack)); + i = VG_(malloc)("stacks.rs.1", sizeof(Stack)); i->start = start; i->end = end; i->id = next_id++; @@ -230,7 +230,7 @@ void VG_(deregister_stack)(UWord id) } else { prev->next = i->next; } - VG_(arena_free)(VG_AR_CORE, i); + VG_(free)(i); return; } prev = i; diff --git a/coregrind/m_syswrap/syswrap-darwin.c b/coregrind/m_syswrap/syswrap-darwin.c index a736f39abf..dc48fbad6a 100644 --- a/coregrind/m_syswrap/syswrap-darwin.c +++ b/coregrind/m_syswrap/syswrap-darwin.c @@ -358,8 +358,7 @@ static Int allocated_port_count = 0; static void port_create_vanilla(mach_port_t port) { OpenPort* op - = VG_(arena_calloc)(VG_AR_CORE, "syswrap-darwin.port_create_vanilla", - sizeof(OpenPort), 1); + = VG_(calloc)("syswrap-darwin.port_create_vanilla", sizeof(OpenPort), 1); op->port = port; /* Add it to the list. */ op->next = allocated_ports; @@ -413,10 +412,10 @@ __private_extern__ void assign_port_name(mach_port_t port, const HChar *name) i = info_for_port(port); vg_assert(i); - if (i->name) VG_(arena_free)(VG_AR_CORE, i->name); + if (i->name) VG_(free)(i->name); i->name = - VG_(arena_malloc)(VG_AR_CORE, "syswrap-darwin.mach-port-name", - VG_(strlen)(name) + PORT_STRLEN + 1); + VG_(malloc)("syswrap-darwin.mach-port-name", + VG_(strlen)(name) + PORT_STRLEN + 1); VG_(sprintf)(i->name, name, port); } @@ -482,8 +481,8 @@ void record_port_mod_refs(mach_port_t port, mach_port_type_t right, Int delta) if(i->next) i->next->prev = i->prev; if(i->name) - VG_(arena_free) (VG_AR_CORE, i->name); - VG_(arena_free) (VG_AR_CORE, i); + VG_(free) (i->name); + VG_(free) (i); allocated_port_count--; return; } @@ -553,8 +552,7 @@ void record_named_port(ThreadId tid, mach_port_t port, /* Not already one: allocate an OpenPort */ if (i == NULL) { - i = VG_(arena_malloc)(VG_AR_CORE, "syswrap-darwin.mach-port", - sizeof(OpenPort)); + i = VG_(malloc)("syswrap-darwin.mach-port", sizeof(OpenPort)); i->prev = NULL; i->next = allocated_ports; @@ -7041,7 +7039,7 @@ POST(bootstrap_look_up) } else { PRINT("not found"); } - VG_(arena_free)(VG_AR_CORE, MACH_ARG(bootstrap_look_up.service_name)); + VG_(free)(MACH_ARG(bootstrap_look_up.service_name)); } PRE(bootstrap_look_up) @@ -7059,8 +7057,7 @@ PRE(bootstrap_look_up) PRINT("bootstrap_look_up(\"%s\")", req->service_name); MACH_ARG(bootstrap_look_up.service_name) = - VG_(arena_strdup)(VG_AR_CORE, "syswrap-darwin.bootstrap-name", - req->service_name); + VG_(strdup)("syswrap-darwin.bootstrap-name", req->service_name); AFTER = POST_FN(bootstrap_look_up); } @@ -8105,7 +8102,7 @@ PRE(sigreturn) static VexGuestX86SegDescr* alloc_zeroed_x86_LDT ( void ) { Int nbytes = VEX_GUEST_X86_LDT_NENT * sizeof(VexGuestX86SegDescr); - return VG_(arena_calloc)(VG_AR_CORE, "syswrap-darwin.ldt", nbytes, 1); + return VG_(calloc)("syswrap-darwin.ldt", nbytes, 1); } #endif diff --git a/coregrind/m_syswrap/syswrap-generic.c b/coregrind/m_syswrap/syswrap-generic.c index 4fd4e50ad1..f3e522efd5 100644 --- a/coregrind/m_syswrap/syswrap-generic.c +++ b/coregrind/m_syswrap/syswrap-generic.c @@ -570,8 +570,8 @@ void record_fd_close(Int fd) if(i->next) i->next->prev = i->prev; if(i->pathname) - VG_(arena_free) (VG_AR_CORE, i->pathname); - VG_(arena_free) (VG_AR_CORE, i); + VG_(free) (i->pathname); + VG_(free) (i); fd_count--; break; } @@ -596,7 +596,7 @@ void ML_(record_fd_open_with_given_name)(ThreadId tid, Int fd, char *pathname) i = allocated_fds; while (i) { if (i->fd == fd) { - if (i->pathname) VG_(arena_free)(VG_AR_CORE, i->pathname); + if (i->pathname) VG_(free)(i->pathname); break; } i = i->next; @@ -604,7 +604,7 @@ void ML_(record_fd_open_with_given_name)(ThreadId tid, Int fd, char *pathname) /* Not already one: allocate an OpenFd */ if (i == NULL) { - i = VG_(arena_malloc)(VG_AR_CORE, "syswrap.rfdowgn.1", sizeof(OpenFd)); + i = VG_(malloc)("syswrap.rfdowgn.1", sizeof(OpenFd)); i->prev = NULL; i->next = allocated_fds; @@ -614,7 +614,7 @@ void ML_(record_fd_open_with_given_name)(ThreadId tid, Int fd, char *pathname) } i->fd = fd; - i->pathname = VG_(arena_strdup)(VG_AR_CORE, "syswrap.rfdowgn.2", pathname); + i->pathname = VG_(strdup)("syswrap.rfdowgn.2", pathname); i->where = (tid == -1) ? NULL : VG_(record_ExeContext)(tid, 0/*first_ip_delta*/); } @@ -926,7 +926,7 @@ void pre_mem_read_sendmsg ( ThreadId tid, Bool read, HChar *outmsg = strdupcat ( "di.syswrap.pmrs.1", "sendmsg", msg, VG_AR_CORE ); PRE_MEM_READ( outmsg, base, size ); - VG_(arena_free) ( VG_AR_CORE, outmsg ); + VG_(free) ( outmsg ); } static @@ -939,7 +939,7 @@ void pre_mem_write_recvmsg ( ThreadId tid, Bool read, PRE_MEM_READ( outmsg, base, size ); else PRE_MEM_WRITE( outmsg, base, size ); - VG_(arena_free) ( VG_AR_CORE, outmsg ); + VG_(free) ( outmsg ); } static @@ -965,7 +965,7 @@ void msghdr_foreachfield ( if ( !msg ) return; - fieldName = VG_(arena_malloc) ( VG_AR_CORE, "di.syswrap.mfef", VG_(strlen)(name) + 32 ); + fieldName = VG_(malloc) ( "di.syswrap.mfef", VG_(strlen)(name) + 32 ); VG_(sprintf) ( fieldName, "(%s)", name ); @@ -1015,7 +1015,7 @@ void msghdr_foreachfield ( (Addr)msg->msg_control, msg->msg_controllen ); } - VG_(arena_free) ( VG_AR_CORE, fieldName ); + VG_(free) ( fieldName ); } static void check_cmsg_for_fds(ThreadId tid, struct vki_msghdr *msg) @@ -1061,8 +1061,8 @@ void pre_mem_read_sockaddr ( ThreadId tid, /* NULL/zero-length sockaddrs are legal */ if ( sa == NULL || salen == 0 ) return; - outmsg = VG_(arena_malloc) ( VG_AR_CORE, "di.syswrap.pmr_sockaddr.1", - VG_(strlen)( description ) + 30 ); + outmsg = VG_(malloc) ( "di.syswrap.pmr_sockaddr.1", + VG_(strlen)( description ) + 30 ); VG_(sprintf) ( outmsg, description, "sa_family" ); PRE_MEM_READ( outmsg, (Addr) &sa->sa_family, sizeof(vki_sa_family_t)); @@ -1131,7 +1131,7 @@ void pre_mem_read_sockaddr ( ThreadId tid, break; } - VG_(arena_free) ( VG_AR_CORE, outmsg ); + VG_(free) ( outmsg ); } /* Dereference a pointer to a UInt. */ diff --git a/coregrind/m_syswrap/syswrap-linux.c b/coregrind/m_syswrap/syswrap-linux.c index 9f6623ef98..19f6833631 100644 --- a/coregrind/m_syswrap/syswrap-linux.c +++ b/coregrind/m_syswrap/syswrap-linux.c @@ -1052,8 +1052,7 @@ POST(sys_prctl) /* Don't bother reusing the memory. This is a rare event. */ tst->thread_name = - VG_(arena_realloc)(VG_AR_CORE, "syswrap.prctl", - tst->thread_name, new_len + 1); + VG_(realloc)("syswrap.prctl", tst->thread_name, new_len + 1); VG_(strcpy)(tst->thread_name, new_name); } } diff --git a/coregrind/m_syswrap/syswrap-x86-linux.c b/coregrind/m_syswrap/syswrap-x86-linux.c index 2ba73f90dc..8271b42e3f 100644 --- a/coregrind/m_syswrap/syswrap-x86-linux.c +++ b/coregrind/m_syswrap/syswrap-x86-linux.c @@ -440,21 +440,21 @@ void translate_to_hw_format ( /* IN */ vki_modify_ldt_t* inn, static VexGuestX86SegDescr* alloc_zeroed_x86_GDT ( void ) { Int nbytes = VEX_GUEST_X86_GDT_NENT * sizeof(VexGuestX86SegDescr); - return VG_(arena_calloc)(VG_AR_CORE, "di.syswrap-x86.azxG.1", nbytes, 1); + return VG_(calloc)("di.syswrap-x86.azxG.1", nbytes, 1); } /* Create a zeroed-out LDT. */ static VexGuestX86SegDescr* alloc_zeroed_x86_LDT ( void ) { Int nbytes = VEX_GUEST_X86_LDT_NENT * sizeof(VexGuestX86SegDescr); - return VG_(arena_calloc)(VG_AR_CORE, "di.syswrap-x86.azxL.1", nbytes, 1); + return VG_(calloc)("di.syswrap-x86.azxL.1", nbytes, 1); } /* Free up an LDT or GDT allocated by the above fns. */ static void free_LDT_or_GDT ( VexGuestX86SegDescr* dt ) { vg_assert(dt); - VG_(arena_free)(VG_AR_CORE, (void*)dt); + VG_(free)(dt); } /* Copy contents between two existing LDTs. */ diff --git a/include/pub_tool_mallocfree.h b/include/pub_tool_mallocfree.h index 0524162c7c..ca69666fe3 100644 --- a/include/pub_tool_mallocfree.h +++ b/include/pub_tool_mallocfree.h @@ -43,6 +43,7 @@ extern void* VG_(malloc) ( const HChar* cc, SizeT nbytes ); extern void VG_(free) ( void* p ); extern void* VG_(calloc) ( const HChar* cc, SizeT n, SizeT bytes_per_elem ); extern void* VG_(realloc) ( const HChar* cc, void* p, SizeT size ); +extern void VG_(realloc_shrink)( void* ptr, SizeT size ); extern HChar* VG_(strdup) ( const HChar* cc, const HChar* s ); // TODO: move somewhere else