From 3a8c55d8151b521f7835ceea4919690408d9e914 Mon Sep 17 00:00:00 2001 From: hadaq Date: Thu, 6 Feb 2003 13:07:00 +0000 Subject: [PATCH] BUGFIX: getenv returns pointer to static -- mm --- allParam/tcl/tclParam.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/allParam/tcl/tclParam.c b/allParam/tcl/tclParam.c index 197621d..9e0c2e7 100644 --- a/allParam/tcl/tclParam.c +++ b/allParam/tcl/tclParam.c @@ -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; } -- 2.43.0