Skip to content

Commit

Permalink
Simplify rpmfi replaced sized management
Browse files Browse the repository at this point in the history
rpmfi always internally stores 64bit sizes since 4.6.0, there's no
reason to do anything else with replaced sizes either.
  • Loading branch information
pmatilai committed May 8, 2024
1 parent 97c0889 commit 0f6ed3c
Showing 1 changed file with 4 additions and 21 deletions.
25 changes: 4 additions & 21 deletions lib/rpmfi.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,7 @@ struct rpmfiles_s {
unsigned char * veritysigs; /*!< Verity signatures in binary. */

struct nlinkHash_s * nlinks;/*!< Files connected by hardlinks */
rpm_off_t * replacedSizes; /*!< (TR_ADDED) */
rpm_loff_t * replacedLSizes;/*!< (TR_ADDED) */
rpm_loff_t * replacedSizes; /*!< (TR_ADDED) */
int magic;
int nrefs; /*!< Reference count. */
};
Expand Down Expand Up @@ -1283,7 +1282,6 @@ rpmfiles rpmfilesFree(rpmfiles fi)
}

fi->replacedSizes = _free(fi->replacedSizes);
fi->replacedLSizes = _free(fi->replacedLSizes);

fi->h = headerFree(fi->h);
fi->pool = rpmstrPoolFree(fi->pool);
Expand Down Expand Up @@ -1864,22 +1862,9 @@ void rpmfilesSetFReplacedSize(rpmfiles fi, int ix, rpm_loff_t newsize)
if (fi != NULL && ix >= 0 && ix < rpmfilesFC(fi)) {
/* Switch over to 64 bit variant */
int fc = rpmfilesFC(fi);
if (newsize > UINT32_MAX && fi->replacedLSizes == NULL) {
fi->replacedLSizes = (rpm_loff_t *)xcalloc(fc, sizeof(*fi->replacedLSizes));
/* copy 32 bit data */
if (fi->replacedSizes) {
for (int i=0; i < fc; i++)
fi->replacedLSizes[i] = fi->replacedSizes[i];
fi->replacedSizes = _free(fi->replacedSizes);
}
}
if (fi->replacedLSizes != NULL) {
fi->replacedLSizes[ix] = newsize;
} else {
if (fi->replacedSizes == NULL)
fi->replacedSizes = (rpm_off_t *)xcalloc(fc, sizeof(*fi->replacedSizes));
fi->replacedSizes[ix] = (rpm_off_t) newsize;
}
if (fi->replacedSizes == NULL)
fi->replacedSizes = (rpm_loff_t *)xcalloc(fc, sizeof(*fi->replacedSizes));
fi->replacedSizes[ix] = newsize;
}
}

Expand All @@ -1889,8 +1874,6 @@ rpm_loff_t rpmfilesFReplacedSize(rpmfiles fi, int ix)
if (fi != NULL && ix >= 0 && ix < rpmfilesFC(fi)) {
if (fi->replacedSizes) {
rsize = fi->replacedSizes[ix];
} else if (fi->replacedLSizes) {
rsize = fi->replacedLSizes[ix];
}
}
return rsize;
Expand Down

0 comments on commit 0f6ed3c

Please sign in to comment.