summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorPanu Matilainen <pmatilai@redhat.com>2008-04-25 14:52:03 +0300
committerPanu Matilainen <pmatilai@redhat.com>2008-04-25 15:29:34 +0300
commit8660bd61f6bbfa20635ef74827b36864d9ec0e7b (patch)
tree107b5da884f3182a4c0dd7058e2790b673bfae0c /lib
parentd49aaeb3b94a7e2e53137e09a517534b080ac444 (diff)
downloadrpm-8660bd61f6bbfa20635ef74827b36864d9ec0e7b.tar.gz
rpm-8660bd61f6bbfa20635ef74827b36864d9ec0e7b.tar.bz2
rpm-8660bd61f6bbfa20635ef74827b36864d9ec0e7b.zip
Reduce alloca() use in relocateFileList()
- dirindexes and filelists can be *huge* - filenames and such still allocated on stack, fix later...
Diffstat (limited to 'lib')
-rw-r--r--lib/rpmfi.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/lib/rpmfi.c b/lib/rpmfi.c
index f5ad8f151..0f3e2cfbf 100644
--- a/lib/rpmfi.c
+++ b/lib/rpmfi.c
@@ -676,7 +676,7 @@ assert(p != NULL);
h = headerLink(origH);
- relocations = alloca(sizeof(*relocations) * numRelocations);
+ relocations = xmalloc(sizeof(*relocations) * numRelocations);
/* Build sorted relocation list from raw relocations. */
for (i = 0; i < numRelocations; i++) {
@@ -802,10 +802,9 @@ assert(p != NULL);
xx = hge(h, RPMTAG_FILECOLORS, NULL, (rpm_data_t *) &fColors, NULL);
xx = hge(h, RPMTAG_FILEMODES, NULL, (rpm_data_t *) &fModes, NULL);
- dColors = alloca(dirCount * sizeof(*dColors));
- memset(dColors, 0, dirCount * sizeof(*dColors));
+ dColors = xcalloc(dirCount, sizeof(*dColors));
- newDirIndexes = alloca(sizeof(*newDirIndexes) * fileCount);
+ newDirIndexes = xmalloc(sizeof(*newDirIndexes) * fileCount);
memcpy(newDirIndexes, dirIndexes, sizeof(*newDirIndexes) * fileCount);
dirIndexes = newDirIndexes;
@@ -1029,7 +1028,10 @@ dColors[j] |= fColors[i];
baseNames = hfd(baseNames, RPM_STRING_ARRAY_TYPE);
dirNames = hfd(dirNames, RPM_STRING_ARRAY_TYPE);
- fn = _free(fn);
+ free(fn);
+ free(relocations);
+ free(newDirIndexes);
+ free(dColors);
return h;
}