macEnv avoid cantProceed

This commit is contained in:
Michael Davidsaver
2011-08-26 16:33:59 -07:00
committed by Michael Davidsaver
parent 503f46ec8c
commit 9a1b6b995e

View File

@@ -13,8 +13,9 @@
#include <stdlib.h>
#include <string.h>
#include <errlog.h>
#define epicsExportSharedSymbols
#include "cantProceed.h"
#include "epicsString.h"
#include "macLib.h"
@@ -27,8 +28,10 @@ macEnvExpand(const char *str)
char *dest = NULL;
int n;
if (macCreateHandle(&handle, pairs))
cantProceed("macEnvExpand: macCreateHandle failed.");
if (macCreateHandle(&handle, pairs)){
errlogMessage("macEnvExpand: macCreateHandle failed.");
return NULL;
}
do {
destCapacity *= 2;
@@ -37,7 +40,10 @@ macEnvExpand(const char *str)
* keep the original contents.
*/
free(dest);
dest = mallocMustSucceed(destCapacity, "macEnvExpand");
dest = malloc(destCapacity);
if(!dest)
goto done;
n = macExpandString(handle, str, dest, destCapacity);
} while (n >= (destCapacity - 1));
@@ -51,7 +57,8 @@ macEnvExpand(const char *str)
dest = realloc(dest, n);
}
done:
if (macDeleteHandle(handle))
cantProceed("macEnvExpand: macDeleteHandle failed.");
errlogMessage("macEnvExpand: macDeleteHandle failed.");
return dest;
}