Move header filecount retrieve from addTE() to rpmfsNew()
authorPanu Matilainen <pmatilai@redhat.com>
Thu, 6 May 2010 12:12:41 +0000 (15:12 +0300)
committerPanu Matilainen <pmatilai@redhat.com>
Thu, 6 May 2010 12:12:41 +0000 (15:12 +0300)
lib/rpmfs.c
lib/rpmfs.h
lib/rpmte.c

index f07603a..a8b1b5b 100644 (file)
@@ -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);
index c9ba8da..d2c66ad 100644 (file)
@@ -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);
index 3209e6f..1b9b167 100644 (file)
@@ -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. */