From: jbj Date: Fri, 8 Oct 1999 16:38:33 +0000 (+0000) Subject: Use xmalloc/xstrdup rather than malloc/strdup. X-Git-Tag: tznext/4.11.0.1.tizen20130304~8772 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8ef4ebd1331eed2ff91feda99a0ad7726a083743;p=tools%2Flibrpm-tizen.git Use xmalloc/xstrdup rather than malloc/strdup. CVS patchset: 3377 CVS date: 1999/10/08 16:38:33 --- diff --git a/lib/depends.c b/lib/depends.c index 3cb5a61..7051bff 100644 --- a/lib/depends.c +++ b/lib/depends.c @@ -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; diff --git a/lib/falloc.c b/lib/falloc.c index f66c7d6..c82032c 100644 --- a/lib/falloc.c +++ b/lib/falloc.c @@ -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; diff --git a/lib/misc.c b/lib/misc.c index 2ddee76..23d22d9 100644 --- a/lib/misc.c +++ b/lib/misc.c @@ -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++) { diff --git a/lib/query.c b/lib/query.c index e367c4a..865c476 100644 --- a/lib/query.c +++ b/lib/query.c @@ -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]); diff --git a/lib/rpmdb.c b/lib/rpmdb.c index 03a7c5b..1a817f1 100644 --- a/lib/rpmdb.c +++ b/lib/rpmdb.c @@ -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]); diff --git a/lib/url.c b/lib/url.c index 54a6865..f40fd76 100644 --- 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;