diff options
author | Panu Matilainen <pmatilai@redhat.com> | 2008-04-25 14:07:31 +0300 |
---|---|---|
committer | Panu Matilainen <pmatilai@redhat.com> | 2008-04-25 15:29:19 +0300 |
commit | ccb9647d4b5c6255ff1b734d565b4873c67e0445 (patch) | |
tree | d0e6103ec2500e4adba0c81e8a1566c3f420bc3a /lib | |
parent | b046a85409cecc5d7efdb75185fe155e0e3e4293 (diff) | |
download | rpm-ccb9647d4b5c6255ff1b734d565b4873c67e0445.tar.gz rpm-ccb9647d4b5c6255ff1b734d565b4873c67e0445.tar.bz2 rpm-ccb9647d4b5c6255ff1b734d565b4873c67e0445.zip |
Avoid alloca() on links in printFileInfo()
- also avoid unnecessary nulling of perms, no point ..
Diffstat (limited to 'lib')
-rw-r--r-- | lib/query.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/lib/query.c b/lib/query.c index f118abac4..41e120fc8 100644 --- a/lib/query.c +++ b/lib/query.c @@ -40,8 +40,8 @@ static void printFileInfo(const char * name, struct tm * tm; static time_t now; static struct tm nowtm; - const char * namefield = name; char * perms = rpmPermsString(mode); + char *link = NULL; /* On first call, grab snapshot of now */ if (now == 0) { @@ -59,9 +59,7 @@ static void printFileInfo(const char * name, /* this knows too much about dev_t */ if (S_ISLNK(mode)) { - char *nf = alloca(strlen(name) + sizeof(" -> ") + strlen(linkto)); - sprintf(nf, "%s -> %s", name, linkto); - namefield = nf; + rasprintf(&link, "%s -> %s", name, linkto); } else if (S_ISCHR(mode)) { perms[0] = 'c'; sprintf(sizefield, "%3u, %3u", ((unsigned)(rdev >> 8) & 0xff), @@ -95,8 +93,10 @@ static void printFileInfo(const char * name, } rpmlog(RPMLOG_NOTICE, "%s %4d %-8s%-8s %10s %s %s\n", perms, - (int)nlink, ownerfield, groupfield, sizefield, timefield, namefield); - perms = _free(perms); + (int)nlink, ownerfield, groupfield, sizefield, timefield, + link ? link : name); + free(perms); + free(link); } int showQueryPackage(QVA_t qva, rpmts ts, Header h) |