From: root Date: Thu, 15 Feb 1996 23:13:08 +0000 (+0000) Subject: make load/unload sort like read/write X-Git-Tag: rpm-4.4-release~5444 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=3e32f9e73a9f088f9513e71bd1335bbe8ebbb533;p=platform%2Fupstream%2Frpm.git make load/unload sort like read/write fix type correction in getEntry() CVS patchset: 291 CVS date: 1996/02/15 23:13:08 --- diff --git a/lib/header.c b/lib/header.c index 7d02b83..eb39ee5 100644 --- a/lib/header.c +++ b/lib/header.c @@ -392,7 +392,8 @@ Header loadHeader(void *pv) h->data_used = dl; h->data = p; - h->fully_sorted = 0; + /* This assumes you only loadHeader() something you unloadHeader()-ed */ + h->fully_sorted = 1; h->mutable = 0; return h; @@ -402,6 +403,7 @@ void *unloadHeader(Header h) { void *p; int_32 *pi; + Header res; pi = p = malloc(2 * sizeof(int_32) + h->entries_used * sizeof(struct indexEntry) + @@ -413,6 +415,9 @@ void *unloadHeader(Header h) pi += h->entries_used * sizeof(struct indexEntry); memcpy(pi, h->data, h->data_used); + res = copyHeader(p); + free(p); + return p; } @@ -642,7 +647,9 @@ int getEntry(Header h, int_32 tag, int_32 * type, void **p, int_32 * c) /* Fall through to STRING_ARRAY_TYPE */ case STRING_ARRAY_TYPE: /* Correction! */ - *type = STRING_ARRAY_TYPE; + if (type) { + *type = STRING_ARRAY_TYPE; + } /* Otherwise, build up an array of char* to return */ x = index->count; *p = malloc(x * sizeof(char *));