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...
This commit is contained in:
parent
d0b0883285
commit
9bde09b599
22
lib/rpmfi.c
22
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) {
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue