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 a5019735-40e9-0310-863c-91ae7b9d1cf9
diff --git a/coregrind/m_coredump/coredump-elf.c b/coregrind/m_coredump/coredump-elf.c
index 61a1ce0..9be2c53 100644
--- a/coregrind/m_coredump/coredump-elf.c
+++ b/coregrind/m_coredump/coredump-elf.c
@@ -169,7 +169,7 @@
    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 @@
    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 f1dd861..e08cfc8 100644
--- a/coregrind/m_errormgr.c
+++ b/coregrind/m_errormgr.c
@@ -824,7 +824,7 @@
       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 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 @@
    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 @@
 
       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 @@
 
       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 @@
             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 @@
 
       // 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 be94234..04ca77c 100644
--- a/coregrind/m_gdbserver/m_gdbserver.c
+++ b/coregrind/m_gdbserver/m_gdbserver.c
@@ -161,13 +161,11 @@
 /* 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 @@
 {
    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 @@
    // 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 @@
    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 @@
    } 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 ca016e9..39e42a2 100644
--- a/coregrind/m_gdbserver/server.h
+++ b/coregrind/m_gdbserver/server.h
@@ -156,11 +156,11 @@
                                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 b3580fc..98c625f 100644
--- a/coregrind/m_libcproc.c
+++ b/coregrind/m_libcproc.c
@@ -114,8 +114,7 @@
    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 @@
    }
 
    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 @@
 
    }  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 @@
    // - 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 @@
 
    // XXX if variable becomes empty, remove it completely?
 
-   VG_(arena_free)(VG_AR_CORE, buf);
+   VG_(free)(buf);
 }
 
 /* ---------------------------------------------------------------------
@@ -309,8 +306,7 @@
 
    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 b3035c7..743aad6 100644
--- a/coregrind/m_main.c
+++ b/coregrind/m_main.c
@@ -1146,7 +1146,7 @@
          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 93b7a2a..9e42c25 100644
--- a/coregrind/m_mallocfree.c
+++ b/coregrind/m_mallocfree.c
@@ -2594,6 +2594,11 @@
    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 effd0ce..14d340a 100644
--- a/coregrind/m_scheduler/scheduler.c
+++ b/coregrind/m_scheduler/scheduler.c
@@ -242,7 +242,7 @@
 	 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 6ce03f8..77c1c8d 100644
--- a/coregrind/m_signals.c
+++ b/coregrind/m_signals.c
@@ -1328,7 +1328,7 @@
 {
    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 @@
    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 d116547..43fd6ba 100644
--- a/coregrind/m_stacks.c
+++ b/coregrind/m_stacks.c
@@ -191,7 +191,7 @@
       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 @@
          } 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 a736f39..dc48fba 100644
--- a/coregrind/m_syswrap/syswrap-darwin.c
+++ b/coregrind/m_syswrap/syswrap-darwin.c
@@ -358,8 +358,7 @@
 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 @@
    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 @@
          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 @@
 
    /* 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 @@
    } 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 @@
    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 @@
 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 4fd4e50..f3e522e 100644
--- a/coregrind/m_syswrap/syswrap-generic.c
+++ b/coregrind/m_syswrap/syswrap-generic.c
@@ -570,8 +570,8 @@
          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 @@
    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 @@
 
    /* 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 @@
    }
 
    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 @@
    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 @@
       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 @@
    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 @@
                      (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 @@
    /* 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 @@
          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 9f6623e..19f6833 100644
--- a/coregrind/m_syswrap/syswrap-linux.c
+++ b/coregrind/m_syswrap/syswrap-linux.c
@@ -1052,8 +1052,7 @@
 
             /* 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 2ba73f9..8271b42 100644
--- a/coregrind/m_syswrap/syswrap-x86-linux.c
+++ b/coregrind/m_syswrap/syswrap-x86-linux.c
@@ -440,21 +440,21 @@
 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 0524162..ca69666 100644
--- a/include/pub_tool_mallocfree.h
+++ b/include/pub_tool_mallocfree.h
@@ -43,6 +43,7 @@
 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