OSSP CVS Repository

ossp - Difference in ossp-pkg/rc/rc_list.c versions 1.5 and 1.6
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [History

ossp-pkg/rc/rc_list.c 1.5 -> 1.6

--- rc_list.c    2003/07/07 13:30:51     1.5
+++ rc_list.c    2003/07/08 15:09:50     1.6
@@ -63,8 +63,11 @@
     if (!kszName)
         return(RC_THROW(RC_ERR_RCF));
     else { /* Only enter block with valid string, strdup can't handle NULL */
+        /* FIXME mlelstv -- why malloc only a single pointer ? */
+        /* FIXME mlelstv -- why malloc when non-wildcard case allocs itself ? */
         pInst->m_ppFilevec = malloc(sizeof (rc_file_t *));
         if (strcmp(kszName, RC_GLOB_WILD)) {
+            /* FIXME mlelstv -- already using two pointes here */
             pInst->m_ppFilevec[0] = rcfileNew(kszName);  /* For an object  */
             pInst->m_ppFilevec[1] = rcfileNew(NULL);     /* For the tail   */
             pInst->m_nFiles = 1;             /* We handle just one rc file */
@@ -110,9 +113,13 @@
                 if (nCount == 0) /* Check out the health of this directory listing */
                     return(RC_THROW(RC_ERR_LOC));
                 nIter = 0; /* Used in the next for block, so initialize */
+                /* FIXME mlelstv -- overwriting m_ppFilevec ?? */
                 pInst->m_ppFilevec = calloc(nCount + 1, sizeof (rc_file_t *));
                 if (!pInst->m_ppFilevec) /* Guard against memory overruns */
                     return(RC_THROW(RC_ERR_MEM));
+                /* FIXME mlelstv -- scanning directory twice, so being unsure
+                 *                  about how many files we have
+                 */
                 if ((pLocdir = opendir(szLocations)) == NULL)
                     return(RC_THROW(RC_ERR_LOC));
 
@@ -149,12 +156,13 @@
     assert(pInst && kszName); /* Dummy check */
 
     /* Iterate through list, searching for a rcfile matching the given name */
-    for (nIter = 0; nIter < pInst->m_nFiles && \
-        strcmp(pInst->m_ppFilevec[nIter]->m_szName, kszName); nIter++);
-    if (nIter < pInst->m_nFiles)
-        return(pInst->m_ppFilevec[nIter]);  /* Name of rcfile in list matched */
-    else
-        return(NULL);                       /* Name did not match any rcfile  */
+    for (nIter = 0; nIter < pInst->m_nFiles; nIter++) {
+        if (strcmp(pInst->m_ppFilevec[nIter]->m_szName, kszName) == 0)
+            /* Name of rcfile in list matched */
+            return(pInst->m_ppFilevec[nIter]);
+    }
+
+    return(NULL);  /* Name did not match any rcfile  */
 }
 
 /************************************************
@@ -171,8 +179,10 @@
     assert(pInst);  /* Verify sanity */
 
     if (pInst->m_ppFilevec) {
+        /* free all rcfiles including extra tail element */
         for (nIter = 0; nIter <= pInst->m_nFiles; nIter++) {
             if (pInst->m_ppFilevec[nIter]) {
+                /* FIXME mlelstv -- should be rcfileDelete() */
                 free(pInst->m_ppFilevec[nIter]); /* Deallocate a rcfile */
                 pInst->m_ppFilevec[nIter] = NULL;
             }

CVSTrac 2.0.1