summaryrefslogtreecommitdiff
path: root/lib/fsm.c
diff options
context:
space:
mode:
authorJindrich Novy <jnovy@redhat.com>2008-04-29 14:59:18 +0200
committerJindrich Novy <jnovy@redhat.com>2008-04-29 14:59:18 +0200
commit498677dad2abb860ca6acd5aaa7aa0ef6d288267 (patch)
treeda1446cb53ec357a0101f523240c6148c978b037 /lib/fsm.c
parentbd9e4ed8d7dec6ab7a247298fa8ce5be67e98f58 (diff)
downloadrpm-498677dad2abb860ca6acd5aaa7aa0ef6d288267.tar.gz
rpm-498677dad2abb860ca6acd5aaa7aa0ef6d288267.tar.bz2
rpm-498677dad2abb860ca6acd5aaa7aa0ef6d288267.zip
Remove useless alloca_strdup()
- and yet more alloca usage in writeFile()
Diffstat (limited to 'lib/fsm.c')
-rw-r--r--lib/fsm.c18
1 files changed, 7 insertions, 11 deletions
diff --git a/lib/fsm.c b/lib/fsm.c
index 58678939d..41882db41 100644
--- a/lib/fsm.c
+++ b/lib/fsm.c
@@ -19,8 +19,6 @@
#include "debug.h"
-#define alloca_strdup(_s) strcpy(alloca(strlen(_s)+1), (_s))
-
#define _FSM_DEBUG 0
int _fsm_debug = _FSM_DEBUG;
@@ -825,24 +823,21 @@ static int writeFile(FSM_t fsm, int writeData)
rc = fsmUNSAFE(fsm, FSM_READLINK);
if (rc) goto exit;
st->st_size = fsm->rdnb;
- symbuf = alloca_strdup(fsm->rdbuf); /* XXX save readlink return. */
+ rstrcat(&symbuf, fsm->rdbuf); /* XXX save readlink return. */
}
if (fsm->mapFlags & CPIO_MAP_ABSOLUTE) {
- int nb = strlen(fsm->dirName) + strlen(fsm->baseName) + sizeof(".");
- char * t = alloca(nb);
- *t = '\0';
- fsm->path = t;
+ fsm->path = NULL;
if (fsm->mapFlags & CPIO_MAP_ADDDOT)
- *t++ = '.';
- t = stpcpy( stpcpy(t, fsm->dirName), fsm->baseName);
+ rstrcat(&fsm->path, ".");
+ rstrscat(&fsm->path, fsm->dirName, fsm->baseName, NULL);
} else if (fsm->mapFlags & CPIO_MAP_PATH) {
rpmfi fi = fsmGetFi(fsm);
- fsm->path =
- (fi->apath ? fi->apath[fsm->ix] + fi->striplen : fi->bnl[fsm->ix]);
+ fsm->path = xstrdup((fi->apath ? fi->apath[fsm->ix] + fi->striplen : fi->bnl[fsm->ix]));
}
rc = fsmNext(fsm, FSM_HWRITE);
+ free(fsm->path);
fsm->path = path;
if (rc) goto exit;
@@ -920,6 +915,7 @@ exit:
(void) fsmNext(fsm, FSM_RCLOSE);
fsm->opath = opath;
fsm->path = path;
+ free(symbuf);
return rc;
}