From 2835e091ae72ba53b3fac478a1e7d080affa4cfe Mon Sep 17 00:00:00 2001 From: Panu Matilainen Date: Fri, 14 Nov 2008 17:16:42 +0200 Subject: [PATCH] Yank rpmfi state update out of rpmtsRun() - stuff it into internal rpmfiUpdateState() function to get it out of sight for now, the mechanism needs some... --- lib/rpmfi.c | 43 +++++++++++++++++++++++++++++++++++++++++++ lib/rpmfi_internal.h | 3 +++ lib/transaction.c | 41 +---------------------------------------- 3 files changed, 47 insertions(+), 40 deletions(-) diff --git a/lib/rpmfi.c b/lib/rpmfi.c index 4b9d26f..7096973 100644 --- a/lib/rpmfi.c +++ b/lib/rpmfi.c @@ -1405,3 +1405,46 @@ fprintf(stderr, "*** fi %p\t%s[%d]\n", fi, Type, (fi ? fi->fc : 0)); /* FIX: rpmfi null annotations */ return rpmfiLink(fi, (fi ? fi->Type : NULL)); } + +rpmfi rpmfiUpdateState(rpmfi fi, rpmts ts, rpmte p) +{ + char * fstates = fi->fstates; + rpmFileAction * actions = fi->actions; + sharedFileInfo replaced = fi->replaced; + rpmte savep; + int numShared = 0; + + if (replaced != NULL) { + for (; replaced->otherPkg; replaced++) { + numShared++; + } + if (numShared > 0) { + replaced = xcalloc(numShared + 1, sizeof(*fi->replaced)); + memcpy(replaced, fi->replaced, + sizeof(*fi->replaced) * (numShared + 1)); + } + } + + fi->fstates = NULL; + fi->actions = NULL; + fi->replaced = NULL; + /* FIX: fi->actions is NULL */ + fi = rpmfiFree(fi); + + savep = rpmtsSetRelocateElement(ts, p); + fi = rpmfiNew(ts, p->h, RPMTAG_BASENAMES, RPMFI_KEEPHEADER); + (void) rpmtsSetRelocateElement(ts, savep); + + if (fi != NULL) { /* XXX can't happen */ + fi->te = p; + free(fi->fstates); + fi->fstates = fstates; + free(fi->actions); + fi->actions = actions; + if (replaced != NULL) + fi->replaced = replaced; + p->fi = fi; + } + return fi; +} + diff --git a/lib/rpmfi_internal.h b/lib/rpmfi_internal.h index 7404623..93f5bfb 100644 --- a/lib/rpmfi_internal.h +++ b/lib/rpmfi_internal.h @@ -113,5 +113,8 @@ struct rpmfi_s { int nrefs; /*!< Reference count. */ }; +RPM_GNUC_INTERNAL +rpmfi rpmfiUpdateState(rpmfi fi, rpmts ts, rpmte p); + #endif /* _RPMFI_INTERNAL_H */ diff --git a/lib/transaction.c b/lib/transaction.c index d904ccc..67c0d58 100644 --- a/lib/transaction.c +++ b/lib/transaction.c @@ -1270,46 +1270,7 @@ int rpmtsRun(rpmts ts, rpmps okProbs, rpmprobFilterFlags ignoreSet) * XXX around a recreated file info set. */ rpmpsmSetFI(psm, NULL); - { - char * fstates = fi->fstates; - rpmFileAction * actions = fi->actions; - sharedFileInfo replaced = fi->replaced; - rpmte savep; - int numShared = 0; - - if (replaced != NULL) { - for (; replaced->otherPkg; replaced++) { - numShared++; - } - if (numShared > 0) { - replaced = xcalloc(numShared + 1, - sizeof(*fi->replaced)); - memcpy(replaced, fi->replaced, - sizeof(*fi->replaced) * (numShared + 1)); - } - } - - fi->fstates = NULL; - fi->actions = NULL; - fi->replaced = NULL; -/* FIX: fi->actions is NULL */ - fi = rpmfiFree(fi); - - savep = rpmtsSetRelocateElement(ts, p); - fi = rpmfiNew(ts, p->h, RPMTAG_BASENAMES, RPMFI_KEEPHEADER); - (void) rpmtsSetRelocateElement(ts, savep); - - if (fi != NULL) { /* XXX can't happen */ - fi->te = p; - fi->fstates = _free(fi->fstates); - fi->fstates = fstates; - fi->actions = _free(fi->actions); - fi->actions = actions; - if (replaced != NULL) - fi->replaced = replaced; - p->fi = fi; - } - } + fi = rpmfiUpdateState(fi, ts, p); rpmpsmSetFI(psm, p->fi); /* FIX: psm->fi may be NULL */ -- 2.7.4