summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPanu Matilainen <pmatilai@redhat.com>2010-05-06 15:12:41 +0300
committerPanu Matilainen <pmatilai@redhat.com>2010-05-06 15:12:41 +0300
commit869004e8fbc265d875d22713016fdb440950a556 (patch)
tree8635d31f2fa7d74467a0cdb9288703e7bb6fa82f
parent27869a523327475a4f809415753e1ec091093d4a (diff)
downloadrpm-869004e8fbc265d875d22713016fdb440950a556.tar.gz
rpm-869004e8fbc265d875d22713016fdb440950a556.tar.bz2
rpm-869004e8fbc265d875d22713016fdb440950a556.zip
Move header filecount retrieve from addTE() to rpmfsNew()
-rw-r--r--lib/rpmfs.c14
-rw-r--r--lib/rpmfs.h2
-rw-r--r--lib/rpmte.c10
3 files changed, 12 insertions, 14 deletions
diff --git a/lib/rpmfs.c b/lib/rpmfs.c
index f07603a35..a8b1b5bed 100644
--- a/lib/rpmfs.c
+++ b/lib/rpmfs.c
@@ -1,4 +1,5 @@
#include "system.h"
+#include <rpm/header.h>
#include "lib/rpmfs.h"
#include "debug.h"
@@ -13,12 +14,17 @@ struct rpmfs_s {
int allocatedReplaced;
};
-rpmfs rpmfsNew(unsigned int fc, rpmElementType type)
+rpmfs rpmfsNew(Header h, rpmElementType type)
{
+ struct rpmtd_s bnames;
rpmfs fs = xcalloc(1, sizeof(*fs));
- fs->fc = fc;
- fs->actions = xmalloc(fc * sizeof(*fs->actions));
- memset(fs->actions, FA_UNKNOWN, fc * sizeof(*fs->actions));
+
+ headerGet(h, RPMTAG_BASENAMES, &bnames, HEADERGET_MINMEM);
+ fs->fc = rpmtdCount(&bnames);
+ rpmtdFreeData(&bnames);
+
+ fs->actions = xmalloc(fs->fc * sizeof(*fs->actions));
+ memset(fs->actions, FA_UNKNOWN, fs->fc * sizeof(*fs->actions));
if (type == TR_ADDED) {
fs->states = xmalloc(sizeof(*fs->states) * fs->fc);
memset(fs->states, RPMFILE_STATE_NORMAL, fs->fc);
diff --git a/lib/rpmfs.h b/lib/rpmfs.h
index c9ba8da53..d2c66ad4f 100644
--- a/lib/rpmfs.h
+++ b/lib/rpmfs.h
@@ -19,7 +19,7 @@ struct sharedFileInfo_s {
};
RPM_GNUC_INTERNAL
-rpmfs rpmfsNew(unsigned int fc, rpmElementType type);
+rpmfs rpmfsNew(Header h, rpmElementType type);
RPM_GNUC_INTERNAL
rpmfs rpmfsFree(rpmfs fs);
diff --git a/lib/rpmte.c b/lib/rpmte.c
index 3209e6ff8..1b9b16765 100644
--- a/lib/rpmte.c
+++ b/lib/rpmte.c
@@ -214,15 +214,7 @@ static void addTE(rpmte p, Header h, fnpyKey key, rpmRelocation * relocs)
p->conflicts = rpmdsNew(h, RPMTAG_CONFLICTNAME, 0);
p->obsoletes = rpmdsNew(h, RPMTAG_OBSOLETENAME, 0);
- {
- // get number of files by hand as rpmfiNew needs p->fs
- struct rpmtd_s bnames;
- headerGet(h, RPMTAG_BASENAMES, &bnames, HEADERGET_MINMEM);
-
- p->fs = rpmfsNew(rpmtdCount(&bnames), p->type);
-
- rpmtdFreeData(&bnames);
- }
+ p->fs = rpmfsNew(h, p->type);
p->fi = getFI(p, h);
/* See if we have pre/posttrans scripts. */