ossp-pkg/rc/rc_anal.c 1.17 -> 1.18
--- rc_anal.c 2003/05/28 13:12:31 1.17
+++ rc_anal.c 2003/05/28 15:09:29 1.18
@@ -57,15 +57,17 @@
{
ex_t Except;
- assert(!(*ppInst)->m_szRcs); /* Rcs should be NULL until we set them */
+ assert(!(*ppInst)->m_pszRcs); /* Rcs should be NULL until we set them */
if (!kszName)
return(RC_THROW(RC_ERR_RCF));
else { /* Only enter block with valid string, strdup can't handle NULL */
- (*ppInst)->m_szRcs = malloc(sizeof(char **));
+ (*ppInst)->m_pszRcs = malloc(sizeof(char **));
if (strcmp(kszName, RC_GLOB_WILD)) {
- (*ppInst)->m_szRcs = malloc(sizeof(*((*ppInst)->m_szRcs)));
- *(*ppInst)->m_szRcs = strdup(kszName);
+ (*ppInst)->m_pszRcs = malloc(sizeof(*((*ppInst)->m_pszRcs)) * 2);
+ (*ppInst)->m_pszRcs[0] = strdup(kszName);
+ (*ppInst)->m_pszRcs[0] = strdup(kszName);
+ (*ppInst)->m_pszRcs[1] = NULL;
(*ppInst)->m_nRcs = 1; /* We handle just one rc file */
}
else { /* Wildcard rcfile indicates we must glob the locs directories */
@@ -199,21 +201,21 @@
if (nCount == 0) /* Check out the health of this directory listing */
return(RC_THROW(RC_ERR_DIR));
else /* Allocate for the string array to hold directory entry names */
- (*ppInst)->m_szRcs = malloc(sizeof((*((*ppInst)->m_szRcs))) * (nCount + 1));
+ (*ppInst)->m_pszRcs = malloc(sizeof(*((*ppInst)->m_pszRcs)) * (nCount + 1));
/* Loop through file index setting rc file names according to dirent */
if ((pLocdir = opendir((*ppInst)->m_szLocs)) == NULL)
return(RC_THROW(RC_ERR_DIR));
for (pDirent = readdir(pLocdir); pDirent; pDirent = readdir(pLocdir)) {
if (!strncmp(pDirent->d_name, "rc.", 3)) {
- (*ppInst)->m_szRcs[nIter] = strdup(pDirent->d_name + \
- strlen("rc.") * sizeof(char));
+ (*ppInst)->m_pszRcs[nIter] = strdup(pDirent->d_name + \
+ strlen("rc.") * sizeof(char));
nIter++;
}
}
closedir(pLocdir);
- (*ppInst)->m_szRcs[nIter] = NULL; /* Terminate */
+ (*ppInst)->m_pszRcs[nIter] = NULL; /* Terminate */
(*ppInst)->m_nRcs = nCount; /* Store how many globbed files there are */
return(RC_THROW(RC_OK));
@@ -254,11 +256,11 @@
assert(pInst); /* Verify sanity */
- if (pInst->m_szRcs && pInst->m_szRcs[nIter])
- while (pInst->m_szRcs[nIter]) /* Rc file names */
- free(pInst->m_szRcs[nIter++]);
- if (pInst->m_szRcs) /* Rc file name index */
- free(pInst->m_szRcs);
+ if (pInst->m_pszRcs && pInst->m_pszRcs[nIter])
+ while (pInst->m_pszRcs[nIter]) /* Rc file names */
+ free(pInst->m_pszRcs[nIter++]);
+ if (pInst->m_pszRcs) /* Rc file name index */
+ free(pInst->m_pszRcs);
if (pInst->m_szTmp) /* Temp file name */
free(pInst->m_szTmp);
if (pInst->m_szFuncs) /* Function file names */
|
|