diff options
-rw-r--r-- | ChangeLog | 8 | ||||
-rw-r--r-- | hash.c | 10 | ||||
-rw-r--r-- | hash.h | 1 |
3 files changed, 19 insertions, 0 deletions
@@ -1,5 +1,13 @@ 2009-11-06 Kaz Kylheku <kkylheku@gmail.com> + Add hash removal. + + * hash.c (remhash): New function. + + * hash.h (remhash): Declared. + +2009-11-06 Kaz Kylheku <kkylheku@gmail.com> + Add hash table growth. hash.c (hash_grow): New function. @@ -246,6 +246,16 @@ obj_t *gethash(obj_t *hash, obj_t *key) return cdr(found); } +obj_t *remhash(obj_t *hash, obj_t *key) +{ + struct hash *h = (struct hash *) hash->co.handle; + obj_t **pchain = vecref_l(h->table, num(ll_hash(key) % h->modulus)); + *pchain = alist_remove1(*pchain, key); + h->count--; + bug_unless (h->count >= 0); + return nil; +} + /* * Called from garbage collector. Hash module must process all weak tables * that were visited during the marking phase, maintained in the list @@ -28,6 +28,7 @@ obj_t *hash_obj(obj_t *); obj_t *make_hash(obj_t *weak_keys, obj_t *weak_vals); obj_t **gethash_l(obj_t *hash, obj_t *key); obj_t *gethash(obj_t *hash, obj_t *key); +obj_t *remhash(obj_t *hash, obj_t *key); void hash_process_weak(void); void hash_init(void); |