diff options
author | Florian Festi <ffesti@redhat.com> | 2010-05-06 15:30:01 +0200 |
---|---|---|
committer | Florian Festi <ffesti@redhat.com> | 2010-05-06 16:07:56 +0200 |
commit | 9fad36f0eddb5d2d63cba6656978c68d7b5b715d (patch) | |
tree | 433717ce22119dbb9146a1ce851661389bcaa87e /lib | |
parent | aafd8500d3235b1c8e54c838924c3f5b490c9148 (diff) | |
download | librpm-tizen-9fad36f0eddb5d2d63cba6656978c68d7b5b715d.tar.gz librpm-tizen-9fad36f0eddb5d2d63cba6656978c68d7b5b715d.tar.bz2 librpm-tizen-9fad36f0eddb5d2d63cba6656978c68d7b5b715d.zip |
rpmhash: new Empty() function to remove all entries
Diffstat (limited to 'lib')
-rw-r--r-- | lib/rpmhash.C | 18 | ||||
-rw-r--r-- | lib/rpmhash.H | 7 |
2 files changed, 22 insertions, 3 deletions
diff --git a/lib/rpmhash.C b/lib/rpmhash.C index dbbb9e4af..1a9921987 100644 --- a/lib/rpmhash.C +++ b/lib/rpmhash.C @@ -152,12 +152,13 @@ void HASHPREFIX(AddEntry)(HASHTYPE ht, HTKEYTYPE key } } -HASHTYPE HASHPREFIX(Free)(HASHTYPE ht) +void HASHPREFIX(Empty)( HASHTYPE ht) { Bucket b, n; int i; - if (ht==NULL) - return ht; + + if (ht->bucketCount == 0) return; + for (i = 0; i < ht->numBuckets; i++) { b = ht->buckets[i]; if (b == NULL) @@ -179,7 +180,18 @@ HASHTYPE HASHPREFIX(Free)(HASHTYPE ht) b = _free(b); } while ((b = n) != NULL); } + ht->bucketCount = 0; + ht->keyCount = 0; +#ifdef HTDATATYPE + ht->dataCount = 0; +#endif +} +HASHTYPE HASHPREFIX(Free)(HASHTYPE ht) +{ + if (ht==NULL) + return ht; + HASHPREFIX(Empty)(ht); ht->buckets = _free(ht->buckets); ht = _free(ht); diff --git a/lib/rpmhash.H b/lib/rpmhash.H index ad791cff9..555ca8583 100644 --- a/lib/rpmhash.H +++ b/lib/rpmhash.H @@ -56,6 +56,13 @@ RPM_GNUC_INTERNAL HASHTYPE HASHPREFIX(Free)( HASHTYPE ht); /** + * Remove all entries from the hash table. + * @param ht pointer to hash table + */ +RPM_GNUC_INTERNAL +void HASHPREFIX(Empty)(HASHTYPE ht); + +/** * Add item to hash table. * @param ht pointer to hash table * @param key key |