[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

gEDA-cvs: gaf.git: branch: master updated (1.5.0-20080706-290-g8112336)



The branch, master has been updated
       via  811233695be6f5d58ba576054d9763be11c6aa4c (commit)
      from  35c1fad3cfab34053fcd850e2a0208db54558baf (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


=========
 Summary
=========

 gschem/src/o_undo.c |   23 +++++++++--------------
 1 files changed, 9 insertions(+), 14 deletions(-)


=================
 Commit Messages
=================

commit 811233695be6f5d58ba576054d9763be11c6aa4c
Author: Peter Clifton <pcjc2@xxxxxxxxx>
Date:   Sun Nov 2 15:25:46 2008 +0000

    gschem: Take copy of "TMP" environment variable with g_strdup()
    
    It isn't gauranteed that the result of getenv can't get modified at
    some point after the call (e.g. by another call to getenv), and testing
    of the mingw32 port has revealed that the returned string was getting
    corrupted at some point.
    
    Take a g_strdup() of the string immediately, so we don't have to worry.
    
    Since capitalised variable names should really be reserved for #define'd
    constants, rename "TMP" to tmp_path.

:100644 100644 be0ea3c... cc4630a... M	gschem/src/o_undo.c

=========
 Changes
=========

commit 811233695be6f5d58ba576054d9763be11c6aa4c
Author: Peter Clifton <pcjc2@xxxxxxxxx>
Date:   Sun Nov 2 15:25:46 2008 +0000

    gschem: Take copy of "TMP" environment variable with g_strdup()
    
    It isn't gauranteed that the result of getenv can't get modified at
    some point after the call (e.g. by another call to getenv), and testing
    of the mingw32 port has revealed that the returned string was getting
    corrupted at some point.
    
    Take a g_strdup() of the string immediately, so we don't have to worry.
    
    Since capitalised variable names should really be reserved for #define'd
    constants, rename "TMP" to tmp_path.

diff --git a/gschem/src/o_undo.c b/gschem/src/o_undo.c
index be0ea3c..cc4630a 100644
--- a/gschem/src/o_undo.c
+++ b/gschem/src/o_undo.c
@@ -37,9 +37,7 @@
 static int undo_file_index=0;
 static int prog_pid=0;
 
-/* TMP environment variable */
-static char* TMP = NULL;
-static int freeTMP = FALSE;
+static char* tmp_path = NULL;
 
 /* this is additional number of levels (or history) at which point the */
 /* undo stack will be trimmed, it's used a safety to prevent running out */ 
@@ -55,13 +53,12 @@ void o_undo_init(void)
 {
   prog_pid = getpid();
 
-  TMP = getenv("TMP");
-  if (!TMP) {
-     TMP = g_strdup ("/tmp");
-     freeTMP = TRUE;
+  tmp_path = g_strdup (getenv("TMP"));
+  if (tmp_path == NULL) {
+     tmp_path = g_strdup ("/tmp");
   }
 #if DEBUG
-  printf("%s\n", TMP);
+  printf("%s\n", tmp_path);
 #endif
 }
 
@@ -101,7 +98,7 @@ void o_undo_savestate(GSCHEM_TOPLEVEL *w_current, int flag)
     }
 
     filename = g_strdup_printf("%s%cgschem.save%d_%d.sch",
-                               TMP, G_DIR_SEPARATOR,
+                               tmp_path, G_DIR_SEPARATOR,
                                prog_pid, undo_file_index++);
 
     /* Changed from f_save to o_save when adding backup copy creation. */
@@ -471,16 +468,14 @@ void o_undo_cleanup(void)
   char *filename;
 
   for (i = 0 ; i < undo_file_index; i++) {
-    filename = g_strdup_printf("%s%cgschem.save%d_%d.sch", TMP,
+    filename = g_strdup_printf("%s%cgschem.save%d_%d.sch", tmp_path,
                                G_DIR_SEPARATOR, prog_pid, i);
     unlink(filename);
     g_free(filename);
   }
 
-  if (freeTMP) {
-    g_free(TMP);
-    TMP = NULL;
-  }
+  g_free(tmp_path);
+  tmp_path = NULL;
 }
 
 /*! \todo Finish function documentation!!!




_______________________________________________
geda-cvs mailing list
geda-cvs@xxxxxxxxxxxxxx
http://www.seul.org/cgi-bin/mailman/listinfo/geda-cvs