]> jspc29.x-matter.uni-frankfurt.de Git - daqdata.git/commitdiff
BUGFIX: getenv returns pointer to static -- mm
authorhadaq <hadaq>
Thu, 6 Feb 2003 13:07:00 +0000 (13:07 +0000)
committerhadaq <hadaq>
Thu, 6 Feb 2003 13:07:00 +0000 (13:07 +0000)
allParam/tcl/tclParam.c

index 197621d06f0820f6dea039f9da8b0b8df14d7b0c..9e0c2e7716ea55bda1932f47d60bec28f277e228 100644 (file)
@@ -1,4 +1,4 @@
-static const char rcsId[] = "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/allParam/tcl/tclParam.c,v 1.26 2003-02-05 16:54:46 hadaq Exp $";
+static const char rcsId[] = "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/allParam/tcl/tclParam.c,v 1.27 2003-02-06 13:07:00 hadaq Exp $";
 #define _POSIX_C_SOURCE 199509L
 
 #if HAVE_CONFIG_H
@@ -88,6 +88,7 @@ int conSetupParam(Param *my, const char *setup)
 int conParam(Param *my)
 {
        int retVal = 0;
+       char *p;
        char *paramFile;
        char *storageFile;
        int code;
@@ -98,14 +99,19 @@ int conParam(Param *my)
        my->setup = NULL;
        my->specParam = malloc(sizeof(TclParam));
 
-       paramFile = getenv("DAQSLOW_PARAM_FILE");
-       if (paramFile == NULL) {
-               paramFile = "param.tcl";
+       p = getenv("DAQSLOW_PARAM_FILE");
+       if (p == NULL) {
+               p = "param.tcl";
        }
-       storageFile = getenv("DAQSLOW_STORAGE_FILE");
-       if (storageFile == NULL) {
-               storageFile = "storage.tcl";
+       paramFile = malloc(strlen(p) + 1);
+       strcpy(paramFile, p);
+
+       p = getenv("DAQSLOW_STORAGE_FILE");
+       if (p == NULL) {
+               p = "storage.tcl";
        }
+       storageFile = malloc(strlen(p) + 1);
+       strcpy(storageFile, p);
 
        ((TclParam *) (my->specParam))->interp = Tcl_CreateInterp();
        code = Tcl_EvalFile(((TclParam *) (my->specParam))->interp, paramFile);
@@ -137,6 +143,9 @@ int conParam(Param *my)
                my->basedir = NULL;
        }
 
+       free(paramFile);
+       free(storageFile);
+
        return retVal;
 }