From 83d22ce16464f100a78fe3ab0bb22483f2b47e5f Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Tue, 26 Aug 2014 14:51:18 -0700 Subject: [PATCH] libCom: Darwin has setenv(), use it. --- src/libCom/osi/os/Darwin/osdEnv.c | 28 +++------------------------- 1 file changed, 3 insertions(+), 25 deletions(-) diff --git a/src/libCom/osi/os/Darwin/osdEnv.c b/src/libCom/osi/os/Darwin/osdEnv.c index 4d957ad87..44c0afa0a 100644 --- a/src/libCom/osi/os/Darwin/osdEnv.c +++ b/src/libCom/osi/os/Darwin/osdEnv.c @@ -25,41 +25,19 @@ * Starting in Mac OS X 10.5 (Leopard) shared libraries and * bundles don't have direct access to environ (man environ). */ -# include -# define environ (*_NSGetEnviron()) +#include +#define environ (*_NSGetEnviron()) #define epicsExportSharedSymbols #include "epicsStdio.h" -#include -#include #include -#include -#include "epicsFindSymbol.h" /* * Set the value of an environment variable - * Leaks memory, but the assumption is that this routine won't be - * called often enough for the leak to be a problem. */ epicsShareFunc void epicsShareAPI epicsEnvSet (const char *name, const char *value) { - char *cp; - - cp = mallocMustSucceed (strlen (name) + strlen (value) + 2, "epicsEnvSet"); - strcpy (cp, name); - strcat (cp, "="); - strcat (cp, value); - if (putenv (cp) < 0) { - errPrintf( - -1L, - __FILE__, - __LINE__, - "Failed to set environment parameter \"%s\" to \"%s\": %s\n", - name, - value, - strerror (errno)); - free (cp); - } + setenv(name, value, 1); } /*