summaryrefslogtreecommitdiff
path: root/rpmio
diff options
context:
space:
mode:
authorPanu Matilainen <pmatilai@redhat.com>2012-09-17 14:48:21 +0300
committerPanu Matilainen <pmatilai@redhat.com>2012-09-17 14:48:21 +0300
commit38fe7e3b478d751610fcfc0c9bbe004a2633fd13 (patch)
treef0ecc083457488a25512f479e11207c7b8a2dfa9 /rpmio
parent46b664b11b425b8641f05f275087b313d2fc0af3 (diff)
downloadlibrpm-tizen-38fe7e3b478d751610fcfc0c9bbe004a2633fd13.tar.gz
librpm-tizen-38fe7e3b478d751610fcfc0c9bbe004a2633fd13.tar.bz2
librpm-tizen-38fe7e3b478d751610fcfc0c9bbe004a2633fd13.zip
More poolHash multiple data-value cleanups
- The only data associated with a pool key is a single id, we dont need an array for that - Change poolHash get-entry return the id directly instead of pointer array
Diffstat (limited to 'rpmio')
-rw-r--r--rpmio/rpmstrpool.c20
1 files changed, 7 insertions, 13 deletions
diff --git a/rpmio/rpmstrpool.c b/rpmio/rpmstrpool.c
index 641876def..ae06d8be2 100644
--- a/rpmio/rpmstrpool.c
+++ b/rpmio/rpmstrpool.c
@@ -19,7 +19,7 @@ typedef struct poolHashBucket_s * poolHashBucket;
struct poolHashBucket_s {
poolHashBucket next;
const char * key;
- rpmsid data[1];
+ rpmsid data;
};
struct poolHash_s {
@@ -100,7 +100,7 @@ static void poolHashAddHEntry(poolHash ht, const char * key, unsigned int keyHas
ht->keyCount += 1;
b = xmalloc(sizeof(*b));
b->key = key;
- b->data[0] = data;
+ b->data = data;
b->next = ht->buckets[hash];
ht->buckets[hash] = b;
@@ -148,15 +148,11 @@ static poolHash poolHashFree(poolHash ht)
return NULL;
}
-static int poolHashGetHEntry(poolHash ht, const char * key, unsigned int keyHash, rpmsid** data)
+static rpmsid poolHashGetHEntry(poolHash ht, const char * key, unsigned int keyHash)
{
- poolHashBucket b;
- int rc = ((b = poolHashfindEntry(ht, key, keyHash)) != NULL);
+ poolHashBucket b = poolHashfindEntry(ht, key, keyHash);
- if (data)
- *data = rc ? b->data : NULL;
-
- return rc;
+ return (b == NULL) ? 0 : b->data;
}
static void poolHashPrintStats(poolHash ht)
@@ -316,10 +312,8 @@ rpmsid rpmstrPoolIdn(rpmstrPool pool, const char *s, size_t slen, int create)
if (pool && pool->hash && s) {
unsigned int hash = poolHashKeyHash(pool->hash, s);
- rpmsid *sids;
- if (poolHashGetHEntry(pool->hash, s, hash, &sids)) {
- sid = sids[0];
- } else if (create && !pool->frozen) {
+ sid = poolHashGetHEntry(pool->hash, s, hash);
+ if (sid == 0 && create && !pool->frozen) {
sid = rpmstrPoolPut(pool, s, slen, hash);
}
}