]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Change the --track-fds code to use VG_AR_CORE rather than
authorJeremy Fitzhardinge <jeremy@valgrind.org>
Tue, 16 Dec 2003 01:48:38 +0000 (01:48 +0000)
committerJeremy Fitzhardinge <jeremy@valgrind.org>
Tue, 16 Dec 2003 01:48:38 +0000 (01:48 +0000)
VG_(malloc)/(strdup), which puts things into VG_AR_SKIN.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2117

coregrind/vg_mylibc.c
coregrind/vg_syscalls.c

index 1fe9d97d3bb78d22bb542a2705ccd7c93b81ad4a..5931db9422ceb038662671a4776c704d3f6b366a 100644 (file)
@@ -968,8 +968,15 @@ Char VG_(toupper) ( Char c )
 __inline__ Char* VG_(arena_strdup) ( ArenaId aid, const Char* s )
 {
    Int   i;
-   Int   len = VG_(strlen)(s) + 1;
-   Char* res = VG_(arena_malloc) (aid, len);
+   Int   len;
+   Char* res;
+
+   if (s == NULL)
+      return NULL;
+
+   len = VG_(strlen)(s) + 1;
+   res = VG_(arena_malloc) (aid, len);
+
    for (i = 0; i < len; i++)
       res[i] = s[i];
    return res;
index 44a8f0cda949ecbb496ce8a9b57d9eb7097150f2..0d16dc1f3d805d3e45f36eecff5d5dfde9f79eab 100644 (file)
@@ -291,7 +291,7 @@ Char *resolve_fname(Int fd)
    if(VG_(readlink)(tmp, buf, PATH_MAX) == -1)
       return NULL;
 
-   return ((buf[0] == '/') ? VG_(strdup)(buf) : NULL);
+   return ((buf[0] == '/') ? VG_(arena_strdup)(VG_AR_CORE, buf) : NULL);
 }
 
 
@@ -311,8 +311,8 @@ void record_fd_close(Int tid, Int fd)
          if(i->next)
             i->next->prev = i->prev;
          if(i->pathname) 
-            VG_(free) (i->pathname);
-         VG_(free) (i);
+            VG_(arena_free) (VG_AR_CORE, i->pathname);
+         VG_(arena_free) (VG_AR_CORE, i);
          fd_count--;
          break;
       }
@@ -339,7 +339,7 @@ void record_fd_open(Int tid, Int fd, char *pathname)
    i = allocated_fds;
    while (i) {
       if (i->fd == fd) {
-         if (i->pathname) VG_(free)(i->pathname);
+         if (i->pathname) VG_(arena_free)(VG_AR_CORE, i->pathname);
          break;
       }
       i = i->next;
@@ -347,7 +347,7 @@ void record_fd_open(Int tid, Int fd, char *pathname)
 
    /* Not already one: allocate an OpenFd */
    if (i == NULL) {
-      i = VG_(malloc)(sizeof(OpenFd));
+      i = VG_(arena_malloc)(VG_AR_CORE, sizeof(OpenFd));
 
       i->prev = NULL;
       i->next = allocated_fds;
@@ -3350,7 +3350,7 @@ POST(open)
       res = -VKI_EMFILE;
    } else {
       if(VG_(clo_track_fds))
-         record_fd_open(tid, res, VG_(strdup)((Char*)arg1));
+         record_fd_open(tid, res, VG_(arena_strdup)(VG_AR_CORE, (Char*)arg1));
    }
    MAYBE_PRINTF("%d\n",res);
 }
@@ -3394,7 +3394,7 @@ POST(creat)
       res = -VKI_EMFILE;
    } else {
       if(VG_(clo_track_fds))
-         record_fd_open(tid, res, VG_(strdup)((Char*)arg1));
+         record_fd_open(tid, res, VG_(arena_strdup)(VG_AR_CORE, (Char*)arg1));
    }
    MAYBE_PRINTF("%d\n",res);
 }