summaryrefslogtreecommitdiff
path: root/assoc.c
diff options
context:
space:
mode:
authorBrad Fitzpatrick <brad@danga.com>2003-06-22 02:52:05 +0000
committerBrad Fitzpatrick <brad@danga.com>2003-06-22 02:52:05 +0000
commit7917af40da246fa99ca27734b31af2ae2ac1b54a (patch)
tree7c5e0da643ba2802f73530c6450e308eb80e0887 /assoc.c
parentf6d334e03c17de77f137e3176245f71e2f356ae0 (diff)
downloadmemcached-7917af40da246fa99ca27734b31af2ae2ac1b54a.tar.gz
misc fixes as suggested by avva. lot of comment updates, mostly.
git-svn-id: http://code.sixapart.com/svn/memcached/trunk@35 b0b603af-a30f-0410-a34e-baf09ae79d0b
Diffstat (limited to 'assoc.c')
-rw-r--r--assoc.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/assoc.c b/assoc.c
index b927f52..2150524 100644
--- a/assoc.c
+++ b/assoc.c
@@ -151,8 +151,8 @@ item *assoc_find(char *key) {
return 0;
}
-/* returns the address of a item* before the key. if *item == 0,
- the item wasn't found, and a new node should be allocated */
+/* returns the address of the item pointer before the key. if *item == 0,
+ the item wasn't found */
static item** _hashitem_before (char *key) {
ub4 hv = hash(key, strlen(key), 0) & hashmask(HASHPOWER);
@@ -164,12 +164,11 @@ static item** _hashitem_before (char *key) {
return pos;
}
+/* Note: this isn't an assoc_update. The key must not already exist to call this */
int assoc_insert(char *key, item *it) {
- item **before = _hashitem_before(key);
- /* Note: in practice, *before is always 0, as the callers always unlink the old
- item before replacing it with a new item of the same key. TODO: assert? */
- it->h_next = *before ? (*before)->h_next : 0;
- *before = it;
+ ub4 hv = hash(key, strlen(key), 0) & hashmask(HASHPOWER);
+ it->h_next = hashtable[hv];
+ hashtable[hv] = it;
return 1;
}
@@ -181,7 +180,7 @@ void assoc_delete(char *key) {
*before = nxt;
return;
}
- /* Note: we actually get here. the callers don't delete things
+ /* Note: we never actually get here. the callers don't delete things
they can't find. TODO: assert? */
}