2 messages in org.apache.incubator.stdcxx-dev[PATCH] STDCXX-1020 memchk in utility...
FromSent OnAttachments
Scott ZhongOct 20, 2008 3:05 pm 
Martin SeborOct 27, 2008 3:54 pm 
Actions with this message:
Paste this link in email or IM:
Paste this link in email or IM:
Atom feed for this thread
Paste this URL into your reader:
Subject:[PATCH] STDCXX-1020 memchk in utility should honor TMPDIR variableActions
From:Scott Zhong (Scot@roguewave.com)
Date:Oct 20, 2008 3:05:24 pm
List:org.apache.incubator.stdcxx-dev

Changelog:

util/memchk.cpp (memchk): use TMPDIR variable from environment if defined.

here is the patch:

Index: util/memchk.cpp =================================================================== --- util/memchk.cpp (revision 702657) +++ util/memchk.cpp (working copy) @@ -67,6 +67,9 @@ # endif #endif // P_tmpdir

+#ifndef PATH_MAX +# define PATH_MAX 1024 +#endif

#if defined (_RWSTD_EDG_ECCP) && !defined (_WIN32)

@@ -116,9 +119,14 @@ // operation away (as SunOS does, for instance) // fd = open ("/dev/null", O_WRONLY);

+ const char *tmpdir = getenv ("TMPDIR"); + if (tmpdir == NULL) { + tmpdir = P_tmpdir; + } + #ifdef _WIN32

- char* const fname = tempnam (P_tmpdir, ".rwmemchk.tmp"); + char* const fname = tempnam (tmpdir, ".rwmemchk.tmp");

if (!fname) return size_t (-1); @@ -137,10 +145,13 @@

#else // !_WIN32

-# define TMP_TEMPLATE P_tmpdir "/rwmemchk-XXXXXX" + char fname_buf [PATH_MAX];

- char fname_buf [] = TMP_TEMPLATE; + size_t len = strlen (tmpdir) - 1;

+ memcpy (fname_buf, tmpdir, len); + memcpy (fname_buf+len, "/rwmemchk-XXXXXX", sizeof + ("/rwmemchk-XXXXXX")); + fd = mkstemp (fname_buf);

if (fd < 0) {