00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #ifndef _MM_HASH_H
00013 #define _MM_HASH_H
00014 #include "mm.h"
00015
00016 typedef void (*MM_HashDtor)(void *);
00017
00018 typedef struct _MM_Bucket {
00019 struct _MM_Bucket *next;
00020 char *key;
00021 int length;
00022 unsigned int hash;
00023 void *data;
00024 } MM_Bucket;
00025
00026 #define MM_HASH_SIZE 1009
00027 typedef struct _Hash {
00028 MM_Bucket *buckets[ MM_HASH_SIZE ];
00029 MM *mm;
00030 MM_HashDtor dtor;
00031 int nElements;
00032 } MM_Hash;
00033
00034 MM_Hash *mm_hash_new(MM *, MM_HashDtor);
00035 void mm_hash_free(MM_Hash *table);
00036 void *mm_hash_find(MM_Hash *table, const void *key, int length);
00037 void mm_hash_add(MM_Hash *table, char *key, int length, void *data);
00038 void mm_hash_delete(MM_Hash *table, char *key, int length);
00039 void mm_hash_update(MM_Hash *table, char *key, int length, void *data);
00040 #endif
00041
00042
00043
00044
00045
00046
00047
00048
00049