- Within rpm there's exactly one caller of headerUnsort() which has
kinda taken care of re-sorting the header on exit, but only if it
returns successfully, meaning the header sort status could've been
left in inconsistent state with implications on consequent
operations on that header. Also this is part of the public API
yet callers have no chance of adjusting the flag when they call it
(and why should they).
- Also dont bother sorting if the header is already in unsorted state.
*/
void headerUnsort(Header h)
{
- qsort(h->index, h->indexUsed, sizeof(*h->index), offsetCmp);
+ if (h->flags & HEADERFLAG_SORTED) {
+ qsort(h->index, h->indexUsed, sizeof(*h->index), offsetCmp);
+ h->flags &= ~HEADERFLAG_SORTED;
+ }
}
unsigned headerSizeof(Header h, int magicp)
if (lengthPtr)
*lengthPtr = len;
- h->flags &= ~HEADERFLAG_SORTED;
headerSort(h);
return (void *) ei;