summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPanu Matilainen <pmatilai@redhat.com>2008-11-18 12:00:10 +0200
committerPanu Matilainen <pmatilai@redhat.com>2008-11-19 12:42:47 +0200
commit9bde09b59969088c06eb6f5b8a2597b2e04bd306 (patch)
tree320a4d5c6ccc6974d87cb65849abbbce94f7fc18
parentd0b088328549c6693b127decbc1b0b8c0513a539 (diff)
downloadrpm-9bde09b59969088c06eb6f5b8a2597b2e04bd306.tar.gz
rpm-9bde09b59969088c06eb6f5b8a2597b2e04bd306.tar.bz2
rpm-9bde09b59969088c06eb6f5b8a2597b2e04bd306.zip
Add + use internal helper function for getting+setting rpmfi replaced sizes
- lazy allocation on set, otherwise there's no replaced size - the getter deals with this transparently - saves a fair bit of memory, by no means everything has replaced files...
-rw-r--r--lib/rpmfi.c22
-rw-r--r--lib/rpmfi_internal.h6
-rw-r--r--lib/transaction.c5
3 files changed, 30 insertions, 3 deletions
diff --git a/lib/rpmfi.c b/lib/rpmfi.c
index 705c77f9a..ee16319eb 100644
--- a/lib/rpmfi.c
+++ b/lib/rpmfi.c
@@ -1443,6 +1443,28 @@ void rpmfiSetFState(rpmfi fi, int ix, rpmfileState state)
}
}
+void rpmfiSetFReplacedSize(rpmfi fi, rpm_loff_t newsize)
+{
+ if (fi != NULL && fi->i >= 0 && fi->i < fi->fc) {
+ if (fi->replacedSizes == NULL) {
+ fi->replacedSizes = xcalloc(fi->fc, sizeof(*fi->replacedSizes));
+ }
+ /* XXX watch out, replacedSizes is not rpm_loff_t (yet) */
+ fi->replacedSizes[fi->i] = (rpm_off_t) newsize;
+ }
+}
+
+rpm_loff_t rpmfiFReplacedSize(rpmfi fi)
+{
+ rpm_loff_t rsize = 0;
+ if (fi != NULL && fi->i >= 0 && fi->i < fi->fc) {
+ if (fi->replacedSizes) {
+ rsize = fi->replacedSizes[fi->i];
+ }
+ }
+ return rsize;
+}
+
FSM_t rpmfiFSM(rpmfi fi)
{
if (fi != NULL && fi->fsm == NULL) {
diff --git a/lib/rpmfi_internal.h b/lib/rpmfi_internal.h
index 96adcddd6..60d3458e1 100644
--- a/lib/rpmfi_internal.h
+++ b/lib/rpmfi_internal.h
@@ -112,6 +112,12 @@ rpmfi rpmfiUpdateState(rpmfi fi, rpmts ts, rpmte p);
RPM_GNUC_INTERNAL
void rpmfiSetFState(rpmfi fi, int ix, rpmfileState state);
+RPM_GNUC_INTERNAL
+void rpmfiSetFReplacedSize(rpmfi fi, rpm_loff_t newsize);
+
+RPM_GNUC_INTERNAL
+rpm_loff_t rpmfiFReplacedSize(rpmfi fi);
+
/* XXX can't be internal as build code needs this */
FSM_t rpmfiFSM(rpmfi fi);
#endif /* _RPMFI_INTERNAL_H */
diff --git a/lib/transaction.c b/lib/transaction.c
index 67c0d58f5..863a38c5e 100644
--- a/lib/transaction.c
+++ b/lib/transaction.c
@@ -163,8 +163,7 @@ static int handleInstInstalledFiles(const rpmts ts,
rpmFileAction action = rpmfiDecideFate(otherFi, fi, skipMissing);
rpmfiSetFAction(fi, action);
}
- /* XXX watch out, replacedSizes is not rpm_loff_t (yet) */
- fi->replacedSizes[fileNum] = (rpm_off_t) rpmfiFSize(otherFi);
+ rpmfiSetFReplacedSize(fi, rpmfiFSize(otherFi));
}
ps = rpmpsFree(ps);
@@ -432,7 +431,7 @@ assert(otherFi != NULL);
/* Update disk space info for a file. */
rpmtsUpdateDSI(ts, fiFps->entry->dev, rpmfiFSize(fi),
- fi->replacedSizes[i], fixupSize, rpmfiFAction(fi));
+ rpmfiFReplacedSize(fi), fixupSize, rpmfiFAction(fi));
}
ps = rpmpsFree(ps);