summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPanu Matilainen <pmatilai@redhat.com>2008-04-25 11:45:35 +0300
committerPanu Matilainen <pmatilai@redhat.com>2008-04-25 15:28:08 +0300
commitf9a95483bb09672c9efdeba82c015c12dd6c7291 (patch)
tree3e2e313a109270238476dcc625d178794877fd26
parentc636733f3628ebf2e10cbf10dfbe7a52cc5e3fea (diff)
downloadrpm-f9a95483bb09672c9efdeba82c015c12dd6c7291.tar.gz
rpm-f9a95483bb09672c9efdeba82c015c12dd6c7291.tar.bz2
rpm-f9a95483bb09672c9efdeba82c015c12dd6c7291.zip
Simplify lookupPackage(), avoid alloca()
-rw-r--r--build/spec.c14
1 files changed, 5 insertions, 9 deletions
diff --git a/build/spec.c b/build/spec.c
index b73d01b04..9f9c6f23a 100644
--- a/build/spec.c
+++ b/build/spec.c
@@ -65,9 +65,9 @@ struct Source * freeSources(struct Source * s)
rpmRC lookupPackage(rpmSpec spec, const char *name, int flag,Package *pkg)
{
const char *pname;
- const char *fullName;
+ char *fullName = NULL;
Package p;
-
+
/* "main" package */
if (name == NULL) {
if (pkg)
@@ -76,17 +76,12 @@ rpmRC lookupPackage(rpmSpec spec, const char *name, int flag,Package *pkg)
}
/* Construct package name */
- { char *n;
if (flag == PART_SUBNAME) {
(void) headerNVR(spec->packages->header, &pname, NULL, NULL);
- fullName = n = alloca(strlen(pname) + 1 + strlen(name) + 1);
- while (*pname != '\0') *n++ = *pname++;
- *n++ = '-';
+ rasprintf(&fullName, "%s-%s", pname, name);
} else {
- fullName = n = alloca(strlen(name)+1);
+ fullName = xstrdup(name);
}
- strcpy(n, name);
- }
/* Locate package with fullName */
for (p = spec->packages; p != NULL; p = p->next) {
@@ -95,6 +90,7 @@ rpmRC lookupPackage(rpmSpec spec, const char *name, int flag,Package *pkg)
break;
}
}
+ free(fullName);
if (pkg)
*pkg = p;