Simplify setPathDefault()
authorPanu Matilainen <pmatilai@redhat.com>
Fri, 25 Apr 2008 10:39:44 +0000 (13:39 +0300)
committerPanu Matilainen <pmatilai@redhat.com>
Fri, 25 Apr 2008 12:28:45 +0000 (15:28 +0300)
- use rpmGetPath() to get sanitized path, avoid alloca()

lib/rpmrc.c

index 18ffd01..9dd9d69 100644 (file)
@@ -438,12 +438,9 @@ static void setPathDefault(const char * macroname, const char * subdir)
 {
 
     if (macroname != NULL) {
-#define        _TOPDIRMACRO    "%{_topdir}/"
-       char *body = alloca(sizeof(_TOPDIRMACRO) + strlen(subdir));
-       strcpy(body, _TOPDIRMACRO);
-       strcat(body, subdir);
+       char *body = rpmGetPath("%{_topdir}/", subdir, NULL);
        addMacro(NULL, macroname, NULL, body, RMIL_DEFAULT);
-#undef _TOPDIRMACRO
+       free(body);
     }
 }