Use xmalloc/xrealloc/xstrdup.
authorjbj <devnull@localhost>
Wed, 20 Oct 1999 21:47:42 +0000 (21:47 +0000)
committerjbj <devnull@localhost>
Wed, 20 Oct 1999 21:47:42 +0000 (21:47 +0000)
CVS patchset: 3388
CVS date: 1999/10/20 21:47:42

lib/fprint.c
lib/transaction.c

index 5fcceef..3c5e3b6 100644 (file)
@@ -6,7 +6,7 @@
 fingerPrintCache fpCacheCreate(int sizeHint) {
     fingerPrintCache fpc;
 
-    fpc = malloc(sizeof(*fpc));
+    fpc = xmalloc(sizeof(*fpc));
     fpc->ht = htCreate(sizeHint * 2, sizeof(char *), hashFunctionString,
                       hashEqualityString);
     return fpc;
@@ -75,15 +75,15 @@ static fingerPrint doLookup(fingerPrintCache cache, const char * dirName,
        if ((cacheHit = cacheContainsDirectory(cache, *buf ? buf : "/"))) {
            fp.entry = cacheHit;
        } else if (!stat(*buf ? buf : "/", &sb)) {
-           newEntry = malloc(sizeof(*fp.entry));
+           newEntry = xmalloc(sizeof(*fp.entry));
            newEntry->ino = sb.st_ino;
            newEntry->dev = sb.st_dev;
            newEntry->isFake = 0;
-           newEntry->dirName = strdup(*buf ? buf : "/");           
+           newEntry->dirName = xstrdup(*buf ? buf : "/");          
            fp.entry = newEntry;
 
            /* XXX FIXME: memory leak */
-           htAddEntry(cache->ht, strdup(*buf ? buf : "/"), fp.entry);
+           htAddEntry(cache->ht, xstrdup(*buf ? buf : "/"), fp.entry);
        }
 
         if (fp.entry) {
index 2ee6a1c..f3513c5 100644 (file)
@@ -448,7 +448,7 @@ static Header relocateFileList(struct availablePackage * alp,
            int k;
 
            haveRelocatedFile = 1;
-           newDirList = malloc(sizeof(*newDirList) * (dirCount + 1));
+           newDirList = xmalloc(sizeof(*newDirList) * (dirCount + 1));
            for (k = 0; k < dirCount; k++) {
                newDirList[k] = alloca(strlen(dirNames[k]) + 1);
                strcpy(newDirList[k], dirNames[k]);
@@ -456,7 +456,7 @@ static Header relocateFileList(struct availablePackage * alp,
            free(dirNames);
            dirNames = newDirList;
        } else {
-           dirNames = realloc(dirNames, 
+           dirNames = xrealloc(dirNames, 
                               sizeof(*dirNames) * (dirCount + 1));
        }