From: Jeremy Fitzhardinge Date: Tue, 16 Dec 2003 01:48:38 +0000 (+0000) Subject: Change the --track-fds code to use VG_AR_CORE rather than X-Git-Tag: svn/VALGRIND_2_1_1~185 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=6d535b779dc4e4b2f1bc3b4deac6750efb637711;p=thirdparty%2Fvalgrind.git Change the --track-fds code to use VG_AR_CORE rather than VG_(malloc)/(strdup), which puts things into VG_AR_SKIN. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2117 --- diff --git a/coregrind/vg_mylibc.c b/coregrind/vg_mylibc.c index 1fe9d97d3b..5931db9422 100644 --- a/coregrind/vg_mylibc.c +++ b/coregrind/vg_mylibc.c @@ -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; diff --git a/coregrind/vg_syscalls.c b/coregrind/vg_syscalls.c index 44a8f0cda9..0d16dc1f3d 100644 --- a/coregrind/vg_syscalls.c +++ b/coregrind/vg_syscalls.c @@ -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); }