diff options
author | Jindrich Novy <jnovy@redhat.com> | 2008-04-28 13:40:56 +0200 |
---|---|---|
committer | Jindrich Novy <jnovy@redhat.com> | 2008-04-28 13:43:08 +0200 |
commit | c729f98edf54306501096b7f45c55ca1f96373f0 (patch) | |
tree | 4245d6da37e3d994b928bee730477ba6272aff72 /rpmdb | |
parent | 811e7be604bc5f557ed5f3b7c711cc2322438761 (diff) | |
download | rpm-c729f98edf54306501096b7f45c55ca1f96373f0.tar.gz rpm-c729f98edf54306501096b7f45c55ca1f96373f0.tar.bz2 rpm-c729f98edf54306501096b7f45c55ca1f96373f0.zip |
Simplify dirName handling in rpmdbFindByFile()
Diffstat (limited to 'rpmdb')
-rw-r--r-- | rpmdb/rpmdb.c | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/rpmdb/rpmdb.c b/rpmdb/rpmdb.c index 9b7380bb1..afb4535e1 100644 --- a/rpmdb/rpmdb.c +++ b/rpmdb/rpmdb.c @@ -1080,13 +1080,8 @@ static int rpmdbFindByFile(rpmdb db, const char * filespec, if (filespec == NULL) return -2; if ((baseName = strrchr(filespec, '/')) != NULL) { - char * t; - size_t len; - - len = baseName - filespec + 1; - t = strncpy(alloca(len + 1), filespec, len); - t[len] = '\0'; - dirName = t; + dirName = strncpy(xmalloc(len + 1), filespec, baseName - filespec + 1); + dirName[len] = '\0'; baseName++; } else { dirName = ""; @@ -1097,6 +1092,7 @@ static int rpmdbFindByFile(rpmdb db, const char * filespec, fpc = fpCacheCreate(20); fp1 = fpLookup(fpc, dirName, baseName, 1); + free(dirName); dbi = dbiOpen(db, RPMTAG_BASENAMES, 0); if (dbi != NULL) { |