Skip to content
Snippets Groups Projects
Commit b0a1e1eb authored by Wayne Lewis's avatar Wayne Lewis
Browse files

Merge branch 'e3-642_fix_var_names_registermodule' into 'master'

e3-642: Use different variable names each time memory is allocated

See merge request e3/e3-require!63
parents c26f72f5 75d20971
No related branches found
No related tags found
No related merge requests found
...@@ -518,7 +518,8 @@ void registerModule(const char *module, const char *version, const char *locatio ...@@ -518,7 +518,8 @@ void registerModule(const char *module, const char *version, const char *locatio
size_t lm = strlen(module) + 1; size_t lm = strlen(module) + 1;
size_t lv = (version ? strlen(version) : 0) + 1; size_t lv = (version ? strlen(version) : 0) + 1;
size_t ll = 1; size_t ll = 1;
char *abslocation = NULL; char *absLocation = NULL;
char *absLocationRequire = NULL;
char *argstring = NULL; char *argstring = NULL;
const char *mylocation; const char *mylocation;
static int firstTime = 1; static int firstTime = 1;
...@@ -539,8 +540,8 @@ void registerModule(const char *module, const char *version, const char *locatio ...@@ -539,8 +540,8 @@ void registerModule(const char *module, const char *version, const char *locatio
if (location) if (location)
{ {
abslocation = realpathSeparator(location); absLocation = realpathSeparator(location);
ll = strlen(abslocation) + 1; ll = strlen(absLocation) + 1;
} }
m = (moduleitem *)malloc(sizeof(moduleitem) + lm + lv + ll); m = (moduleitem *)malloc(sizeof(moduleitem) + lm + lv + ll);
if (m == NULL) if (m == NULL)
...@@ -553,9 +554,9 @@ void registerModule(const char *module, const char *version, const char *locatio ...@@ -553,9 +554,9 @@ void registerModule(const char *module, const char *version, const char *locatio
strcpy(m->content, module); strcpy(m->content, module);
strcpy(m->content + lm, version); strcpy(m->content + lm, version);
strcpy(m->content + lm + lv, abslocation ? abslocation : ""); strcpy(m->content + lm + lv, absLocation ? absLocation : "");
free(abslocation); free(absLocation);
for (pm = &loadedModules; *pm != NULL; pm = &(*pm)->next) for (pm = &loadedModules; *pm != NULL; pm = &(*pm)->next)
; ;
*pm = m; *pm = m;
...@@ -580,7 +581,7 @@ void registerModule(const char *module, const char *version, const char *locatio ...@@ -580,7 +581,7 @@ void registerModule(const char *module, const char *version, const char *locatio
mylocation = getenv("require_DIR"); mylocation = getenv("require_DIR");
if (mylocation == NULL) if (mylocation == NULL)
return; return;
if (asprintf(&abslocation, "%s" OSI_PATH_SEPARATOR "db" OSI_PATH_SEPARATOR "moduleversion.template", mylocation) < 0) if (asprintf(&absLocationRequire, "%s" OSI_PATH_SEPARATOR "db" OSI_PATH_SEPARATOR "moduleversion.template", mylocation) < 0)
return; return;
/* /*
Require DB has the following four PVs: Require DB has the following four PVs:
...@@ -597,9 +598,9 @@ void registerModule(const char *module, const char *version, const char *locatio ...@@ -597,9 +598,9 @@ void registerModule(const char *module, const char *version, const char *locatio
moduleListBufferSize + maxModuleNameLength * moduleCount) < 0) moduleListBufferSize + maxModuleNameLength * moduleCount) < 0)
return; return;
printf("Loading module info records for %s\n", module); printf("Loading module info records for %s\n", module);
dbLoadRecords(abslocation, argstring); dbLoadRecords(absLocationRequire, argstring);
free(argstring); free(argstring);
free(abslocation); free(absLocationRequire);
} }
#if defined(__linux) #if defined(__linux)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment