Use xmalloc/xstrdup rather than malloc/strdup.
authorjbj <devnull@localhost>
Fri, 8 Oct 1999 16:38:33 +0000 (16:38 +0000)
committerjbj <devnull@localhost>
Fri, 8 Oct 1999 16:38:33 +0000 (16:38 +0000)
CVS patchset: 3377
CVS date: 1999/10/08 16:38:33

lib/depends.c
lib/falloc.c
lib/misc.c
lib/query.c
lib/rpmdb.c
lib/url.c

index 3cb5a61..7051bff 100644 (file)
@@ -212,7 +212,7 @@ static /*@exposed@*/ struct availablePackage * alAddPackage(struct availableList
            if (dirMatch) {
                dirMapping[dirNum] = dirMatch - al->dirs;
            } else {
-               al->dirs[al->numDirs].dirName = strdup(dirList[dirNum]);
+               al->dirs[al->numDirs].dirName = xstrdup(dirList[dirNum]);
                al->dirs[al->numDirs].files = NULL;
                al->dirs[al->numDirs].numFiles = 0;
                al->dirs[al->numDirs].dirNum = al->numDirs;
@@ -734,7 +734,7 @@ void rpmdepFreeConflicts(struct rpmDependencyConflict * conflicts, int
 static struct availablePackage * alFileSatisfiesDepend(
        struct availableList * al, const char * keyType, const char *fileName) {
     int i;
-    char * file = strdup(fileName);
+    char * file = xstrdup(fileName);
     char * chptr = strrchr(file, '/');
     char * base;
     struct dirInfo dirNeedle;
index f66c7d6..c82032c 100644 (file)
@@ -107,7 +107,6 @@ faFile faOpen(const char * path, int flags, int perms)
        fas.fileSize = faLseek(&fas, 0, SEEK_CUR);
     }
 
-    /* XXX xmalloc is inappopriate here */
     if ((fa = malloc(sizeof(*fa))) != NULL) {
        fa->fd = fas.fd;
        fa->readOnly = fas.readOnly;
index 2ddee76..23d22d9 100644 (file)
@@ -184,7 +184,7 @@ int dosetenv(const char *name, const char *value, int overwrite) {
     if (!overwrite && getenv(name)) return 0;
 
     i = strlen(name) + strlen(value) + 2;
-    a = malloc(i);
+    a = xmalloc(i);
     if (!a) return 1;
     
     strcpy(a, name);
@@ -463,7 +463,7 @@ void compressFilelist(Header h) {
 }
 
 /* this is pretty straight-forward. The only thing that even resembles a trick
-   is getting all of this into a single malloc'd block */
+   is getting all of this into a single xmalloc'd block */
 void buildFileList(Header h, char *** fileListPtr, int * fileCountPtr) {
     int * dirList;
     char ** dirs;
@@ -489,7 +489,7 @@ void buildFileList(Header h, char *** fileListPtr, int * fileCountPtr) {
        size += strlen(tails[i]) + strlen(dirs[dirList[i]]) + 1;
     }
 
-    fileList = malloc(size);
+    fileList = xmalloc(size);
     data = ((char *) fileList) + (sizeof(*fileList) * count);
 
     for (i = 0; i < count; i++) {
index e367c4a..865c476 100644 (file)
@@ -285,7 +285,7 @@ int showQueryPackage(QVA_t *qva, /*@unused@*/rpmdb db, Header h)
                        } else {
                            char * filespec;
 
-                           filespec = malloc(strlen(dirList[dirIndexList[i]])
+                           filespec = xmalloc(strlen(dirList[dirIndexList[i]])
                                              + strlen(baseNameList[i]) + 1);
                            strcpy(filespec, dirList[dirIndexList[i]]);
                            strcat(filespec, baseNameList[i]);
index 03a7c5b..1a817f1 100644 (file)
@@ -394,7 +394,7 @@ int rpmdbFindByFile(rpmdb db, const char * filespec, dbiIndexSet * matches)
 
        do {
            num = allMatches.recs[i].fileNumber;
-           otherFile = malloc(strlen(dirNames[dirIndexes[num]]) + 
+           otherFile = xmalloc(strlen(dirNames[dirIndexes[num]]) + 
                              strlen(baseNames[num]) + 1);
            strcpy(otherFile, dirNames[dirIndexes[num]]);
            strcat(otherFile, baseNames[num]);
index 54a6865..f40fd76 100644 (file)
--- a/lib/url.c
+++ b/lib/url.c
@@ -46,7 +46,7 @@ void freeUrlinfo(urlinfo *u)
 urlinfo *newUrlinfo(void)
 {
     urlinfo *u;
-    if ((u = malloc(sizeof(*u))) == NULL)
+    if ((u = xmalloc(sizeof(*u))) == NULL)
        return NULL;
     memset(u, 0, sizeof(*u));
     u->proxyp = -1;