X-Git-Url: http://andersk.mit.edu/gitweb/moira.git/blobdiff_plain/b93ad4221f3b60a851a9986f7d3841847075a2c8..c87509c1fa2e1f024b790f48dfe2f3a6c2e40c83:/lib/hash.c diff --git a/lib/hash.c b/lib/hash.c index 18675c11..200fae56 100644 --- a/lib/hash.c +++ b/lib/hash.c @@ -1,10 +1,16 @@ /* $Header$ * * Generic hash table routines. Uses integer keys to store char * values. + * + * (c) Copyright 1988 by the Massachusetts Institute of Technology. + * For copying and distribution information, please see the file + * . */ +#include #include -#include "sms_app.h" +#include + #define NULL 0 @@ -118,6 +124,24 @@ void (*callback)(); } +/* Step through the hash table, calling the callback proc with each key. + */ + +hash_step(h, callback, hint) +struct hash *h; +void (*callback)(); +char *hint; +{ + register struct bucket *b, **p; + + for (p = &(h->data[h->size - 1]); p >= h->data; p--) { + for (b = *p; b; b = b->next) { + (*callback)(b->key, b->data, hint); + } + } +} + + /* Deallocate all of the memory associated with a table */ hash_destroy(h)