|
From: <sv...@va...> - 2014-09-27 16:51:30
|
Author: florian
Date: Sat Sep 27 17:51:22 2014
New Revision: 14577
Log:
Minor touch-ups for VG_(record_startup_wd).
- Use 500 instead of PATH_MAX as the initial size of the buffer
to hold the directory name. Should be more than enough in the
majority of cases.
- Use VG_(realloc) instead of VG_(arena_realloc).
Modified:
branches/BUF_REMOVAL/coregrind/m_libcfile.c
Modified: branches/BUF_REMOVAL/coregrind/m_libcfile.c
==============================================================================
--- branches/BUF_REMOVAL/coregrind/m_libcfile.c (original)
+++ branches/BUF_REMOVAL/coregrind/m_libcfile.c Sat Sep 27 17:51:22 2014
@@ -427,10 +427,9 @@
}
/* The working directory at startup.
- All that is really needed is to note the cwd at
- process startup. Hence VG_(record_startup_wd) notes it (in a
- platform dependent way) and VG_(get_startup_wd) produces the noted
- value. Hence: */
+ All that is really needed is to note the cwd at process startup.
+ Hence VG_(record_startup_wd) notes it (in a platform dependent way)
+ and VG_(get_startup_wd) produces the noted value. */
static HChar *startup_wd;
static Bool startup_wd_acquired = False;
@@ -441,16 +440,15 @@
there is a problem. */
Bool VG_(record_startup_wd) ( void )
{
- Int szB = 0;
vg_assert(!startup_wd_acquired);
# if defined(VGO_linux)
/* Simple: just ask the kernel */
SysRes res;
+ SizeT szB = 0;
do {
- szB += VKI_PATH_MAX;
- startup_wd =
- VG_(arena_realloc)(VG_AR_CORE, "startup_wd", startup_wd, szB);
+ szB += 500;
+ startup_wd = VG_(realloc)("startup_wd", startup_wd, szB);
VG_(memset)(startup_wd, 0, szB);
res = VG_(do_syscall2)(__NR_getcwd, (UWord)startup_wd, szB-1);
} while (sr_isError(res));
@@ -465,7 +463,7 @@
parent's PID, not ours, since our parent is the launcher
process. */
{ HChar envvar[100]; // large enough
- HChar* wd = NULL;
+ HChar* wd;
VG_(memset)(envvar, 0, sizeof(envvar));
VG_(sprintf)(envvar, "VALGRIND_STARTUP_PWD_%d_XYZZY",
(Int)VG_(getppid)());
@@ -473,7 +471,7 @@
if (wd == NULL)
return False;
SizeT need = VG_(strlen)(wd) + 1;
- startup_wd = VG_(arena_malloc)(VG_AR_CORE, "startup_wd", need);
+ startup_wd = VG_(malloc)(VG_AR_CORE, "startup_wd", need);
VG_(strcpy)(startup_wd, wd);
startup_wd_acquired = True;
return True;
|