X-Git-Url: http://git.madism.org/?p=apps%2Fmadmutt.git;a=blobdiff_plain;f=hash.c;h=0e2192bfe8a4b9485054490649a3142a31c55373;hp=cb2cf2e4c318dbdce5c03f22adb1b6b8799ac395;hb=ef7b80006ebb47372d69c64e8b2b2f0764333d55;hpb=ba5e3af4ea19e1d20c80941c077039871ec84258 diff --git a/hash.c b/hash.c index cb2cf2e..0e2192b 100644 --- a/hash.c +++ b/hash.c @@ -77,7 +77,7 @@ HASH *hash_resize (HASH * ptr, int nelem) * data data to associate with `key' * allow_dup if nonzero, duplicate keys are allowed in the table */ -int hash_insert (HASH * table, const char *key, void *data, int allow_dup) +int hash_insert (HASH * table, const char *key, const void *data, int allow_dup) { struct hash_elem *ptr; int h; @@ -168,3 +168,17 @@ void hash_destroy (HASH ** ptr, void (*destroy) (void *)) mem_free (&pptr->table); mem_free (ptr); } + +void hash_map (HASH* table, void (*mapfunc) (const char* key, void* data, + unsigned long more), + unsigned long more) { + int i = 0; + struct hash_elem* elem = NULL; + + if (!table || !mapfunc) + return; + + for (i = 0; i < table->nelem; i++) + for (elem = table->table[i]; elem; elem = elem->next) + mapfunc (elem->key, elem->data, more); +}