From d085f045de290ae6bd6814ac1484fa0cd61fcdc2 Mon Sep 17 00:00:00 2001 From: Angel Ortega Date: Thu, 9 Dec 2010 15:24:19 +0100 Subject: [PATCH] Moved back hset() to mpdm_hset(). --- mpdm_h.c | 40 +++++++++++++++++----------------------- 1 file changed, 17 insertions(+), 23 deletions(-) diff --git a/mpdm_h.c b/mpdm_h.c index ee3a7da..5d6054a 100644 --- a/mpdm_h.c +++ b/mpdm_h.c @@ -183,7 +183,18 @@ int mpdm_exists(const mpdm_t h, const mpdm_t k) } -static mpdm_t hset(mpdm_t h, mpdm_t k, const wchar_t *ks, mpdm_t v) +/** + * mpdm_hset - Sets a value in a hash. + * @h: the hash + * @k: the key + * @v: the value + * + * Sets the value @v to the key @k in the hash @h. Returns + * the new value (versions prior to 1.0.10 returned the old + * value). + * [Hashes] + */ +mpdm_t mpdm_hset(mpdm_t h, mpdm_t k, mpdm_t v) { mpdm_t b, r; int n; @@ -196,20 +207,20 @@ static mpdm_t hset(mpdm_t h, mpdm_t k, const wchar_t *ks, mpdm_t v) if (mpdm_size(h) == 0) mpdm_expand(h, 0, mpdm->hash_buckets); - n = ks ? HASH_BUCKET_S(h, ks) : HASH_BUCKET(h, k); + n = HASH_BUCKET(h, k); if ((b = mpdm_aget(h, n)) != NULL) { int pos; /* bucket exists; try to find the key there */ - n = ks ? mpdm_bseek_s(b, ks, 2, &pos) : mpdm_bseek(b, k, 2, &pos); + n = mpdm_bseek(b, k, 2, &pos); if (n < 0) { /* the pair does not exist: create it */ n = pos; mpdm_expand(b, n, 2); - mpdm_aset(b, ks ? MPDM_S(ks) : k, n); + mpdm_aset(b, k, n); } } else { @@ -223,7 +234,7 @@ static mpdm_t hset(mpdm_t h, mpdm_t k, const wchar_t *ks, mpdm_t v) n = 0; /* insert the key */ - mpdm_aset(b, ks ? MPDM_S(ks) : k, n); + mpdm_aset(b, k, n); } r = mpdm_aset(b, v, n + 1); @@ -237,23 +248,6 @@ static mpdm_t hset(mpdm_t h, mpdm_t k, const wchar_t *ks, mpdm_t v) /** - * mpdm_hset - Sets a value in a hash. - * @h: the hash - * @k: the key - * @v: the value - * - * Sets the value @v to the key @k in the hash @h. Returns - * the new value (versions prior to 1.0.10 returned the old - * value). - * [Hashes] - */ -mpdm_t mpdm_hset(mpdm_t h, mpdm_t k, mpdm_t v) -{ - return hset(h, k, NULL, v); -} - - -/** * mpdm_hset_s - Sets a value in a hash (string version). * @h: the hash * @k: the key @@ -266,7 +260,7 @@ mpdm_t mpdm_hset(mpdm_t h, mpdm_t k, mpdm_t v) */ mpdm_t mpdm_hset_s(mpdm_t h, const wchar_t *k, mpdm_t v) { - return hset(h, NULL, k, v); + return mpdm_hset(h, MPDM_S(k), v); } -- 2.11.4.GIT