From e87f32f6e9954a728b65047c904904711a3262a1 Mon Sep 17 00:00:00 2001 From: Marty Kraimer Date: Thu, 22 Feb 2001 19:39:02 +0000 Subject: [PATCH] strdup not available on vxWorks --- src/iocsh/iocUtil.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/iocsh/iocUtil.c b/src/iocsh/iocUtil.c index a267bf8b1..48e5e4bfa 100644 --- a/src/iocsh/iocUtil.c +++ b/src/iocsh/iocUtil.c @@ -110,6 +110,7 @@ static const ioccrfArg * const putenvArgs[1] = {&putenvArg0}; static const ioccrfFuncDef putenvFuncDef = {"putenv",1,putenvArgs}; static void putenvCallFunc(const ioccrfArgBuf *args) { + char *arg0 = args[0].sval; char *cp; /* @@ -119,9 +120,9 @@ static void putenvCallFunc(const ioccrfArgBuf *args) * Yes, this will cause memory leaks if the same variable is * placed in the environment more than once. */ - if (!args[0].sval) - return; - cp = strdup (args[0].sval); + if (arg0) return; + cp = calloc(strlen(arg0)+1,sizeof(char)); + strcpy(cp,arg0); if ((cp == NULL) || putenv (cp)) { free (cp); printf ("putenv(%s) failed.\n", args[0].sval);