incubator-stdcxx-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Scott Zhong" <Scott.Zh...@roguewave.com>
Subject [PATCH] STDCXX-1020 memchk in utility should honor TMPDIR variable
Date Wed, 08 Oct 2008 17:14:10 GMT
https://issues.apache.org/jira/browse/STDCXX-1020

Index: util/memchk.cpp
===================================================================
--- util/memchk.cpp     (revision 702657)
+++ util/memchk.cpp     (working copy)
@@ -116,9 +116,11 @@
         // operation away (as SunOS does, for instance)
         // fd = open ("/dev/null", O_WRONLY);
 
+     char *tmpdir = getenv ("TMPDIR") == NULL ? P_tmpdir : getenv
("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 +139,13 @@
 
 #else   // !_WIN32
 
-#  define TMP_TEMPLATE P_tmpdir "/rwmemchk-XXXXXX"
+        char fname_buf [sizeof (tmpdir) + sizeof ("/rwmemchk-XXXXXX")];
 
-        char fname_buf [] = TMP_TEMPLATE;
+        size_t len = sizeof (tmpdir) - 1;
 
+        memcpy (fname_buf, tmpdir, len);
+        memcpy (fname_buf+len, "/rwmemchk-XXXXXX", sizeof
("/rwmemchk-XXXXXX"));
+
         fd = mkstemp (fname_buf);
 
         if (fd < 0) {

Mime
View raw message