Stop messing with fi->fstates allocations in psm
authorPanu Matilainen <pmatilai@redhat.com>
Wed, 5 Nov 2008 12:10:16 +0000 (14:10 +0200)
committerPanu Matilainen <pmatilai@redhat.com>
Wed, 5 Nov 2008 12:10:16 +0000 (14:10 +0200)
- it's alloced and freed by rpmfiNew()/Free() always anyway

lib/psm.c
lib/rpmfi.c

index abf3b5d..3b74379 100644 (file)
--- a/lib/psm.c
+++ b/lib/psm.c
@@ -1276,12 +1276,6 @@ assert(psm->mi == NULL);
            psm->mi = rpmdbFreeIterator(psm->mi);
            rc = RPMRC_OK;
 
-           /* XXX lazy alloc here may need to be done elsewhere. */
-           if (fi->fstates == NULL && fc > 0) {
-               fi->fstates = xmalloc(sizeof(*fi->fstates) * fc);
-               memset(fi->fstates, RPMFILE_STATE_NORMAL, fc);
-           }
-
            if (rpmtsFlags(ts) & RPMTRANS_FLAG_JUSTDB)  break;
            if (fc <= 0)                                break;
        
@@ -1591,7 +1585,6 @@ assert(psm->mi == NULL);
        psm->failedFile = _free(psm->failedFile);
 
        fi->apath = _free(fi->apath);
-       fi->fstates = _free(fi->fstates);
        break;
 
     case PSM_PKGINSTALL:
index a2803b5..26159f7 100644 (file)
@@ -1266,9 +1266,13 @@ rpmfi rpmfiNew(const rpmts ts, Header h, rpmTag tagN, rpmfiFlags flags)
        _hgfi(h, RPMTAG_FILEDEPENDSN, &td, scareFlags, fi->fddictn);
     }
 
+    /* XXX States not needed by TR_REMOVED */
     _hgfi(h, RPMTAG_FILESTATES, &td, defFlags, fi->fstates);
-    if (fi->fstates == NULL)
-       fi->fstates = xcalloc(fi->fc, sizeof(*fi->fstates));
+    if (fi->fstates == NULL) {
+       fi->fstates = xmalloc(sizeof(*fi->fstates) * fi->fc);
+       /* XXX means we show state "normal" when package not even installed */
+       memset(fi->fstates, RPMFILE_STATE_NORMAL, fi->fc);
+    }
 
     _hgfi(h, RPMTAG_FILECAPS, &td, defFlags, fi->fcaps);