Remember data (allocation) size of non-extension data from headerGet()
- Add size member to rpmtd_s and accessor function to get it. For now only works for data marked with RPMTD_IMMUTABLE. - This is redundant for BIN type, but especially for string types this info is impossible to get without walking the entire data.
This commit is contained in:
parent
2a2cecda95
commit
cff6a5d991
|
@ -1176,6 +1176,7 @@ static int copyTdEntry(const indexEntry entry, rpmtd td, headerGetFlags flags)
|
|||
}
|
||||
td->type = entry->info.type;
|
||||
td->count = count;
|
||||
td->size = entry->length;
|
||||
|
||||
if (td->data && entry->data != td->data) {
|
||||
td->flags |= RPMTD_ALLOCED;
|
||||
|
|
|
@ -57,6 +57,11 @@ rpm_count_t rpmtdCount(rpmtd td)
|
|||
return (td->type == RPM_BIN_TYPE) ? 1 : td->count;
|
||||
}
|
||||
|
||||
rpm_count_t rpmtdSize(rpmtd td)
|
||||
{
|
||||
return (td != NULL) ? td->size : 0;
|
||||
}
|
||||
|
||||
rpmTagVal rpmtdTag(rpmtd td)
|
||||
{
|
||||
assert(td != NULL);
|
||||
|
|
|
@ -30,6 +30,7 @@ struct rpmtd_s {
|
|||
rpm_data_t data; /* pointer to actual data */
|
||||
rpmtdFlags flags; /* flags on memory allocation etc */
|
||||
int ix; /* iteration index */
|
||||
rpm_count_t size; /* size of data (only works for RPMTD_IMMUTABLE atm) */
|
||||
};
|
||||
|
||||
/** \ingroup rpmtd
|
||||
|
@ -66,6 +67,14 @@ void rpmtdFreeData(rpmtd td);
|
|||
*/
|
||||
rpm_count_t rpmtdCount(rpmtd td);
|
||||
|
||||
/** \ingroup rpmtd
|
||||
* Retrieve container data size (eg required for allocation).
|
||||
* Note this currently only works for RPMTD_IMMUTABLE data.
|
||||
* @param td Tag data container
|
||||
* @return Data size in bytes.
|
||||
*/
|
||||
rpm_count_t rpmtdSize(rpmtd td);
|
||||
|
||||
/** \ingroup rpmtd
|
||||
* Retrieve tag of the container.
|
||||
* @param td Tag data container
|
||||
|
|
Loading…
Reference in New Issue