diff --git a/mfscommon/dictionary.c b/mfscommon/dictionary.c index c3476e26..8d5ca4e7 100644 --- a/mfscommon/dictionary.c +++ b/mfscommon/dictionary.c @@ -63,229 +63,10 @@ static inline uint32_t GLUE_FN_NAME_PREFIX(_hash)(HASH_ARGS_TYPE_LIST) { return hash; } -static inline uint32_t GLUE_FN_NAME_PREFIX(_ehash)(ENTRY_TYPE *e) { - return GLUE_FN_NAME_PREFIX(_hash)(e->data,e->leng); -} +// GLUE_FN_NAME_PREFIX(_ehash) is needed only if HASH_VALUE_FIELD is not defined !!! #include "hash_begin.h" -#if 0 - -#define HASHTAB_LOBITS 20 -#define HASHTAB_HISIZE (0x80000000>>(HASHTAB_LOBITS)) -#define HASHTAB_LOSIZE (1<>=1; - res<<=1; - } - if (res==0) { - res = UINT32_C(0x80000000); - } - if (res=dicthashsize) { // rehash complete - dictrehashpos = dicthashsize; - return; - } - if (dicthashtab[dictrehashpos >> HASHTAB_LOBITS]==NULL) { -#ifdef HAVE_MMAP - dicthashtab[dictrehashpos >> HASHTAB_LOBITS] = mmap(NULL,sizeof(dictentry*)*HASHTAB_LOSIZE,PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE,-1,0); -#else - dicthashtab[dictrehashpos >> HASHTAB_LOBITS] = malloc(sizeof(dictentry*)*HASHTAB_LOSIZE); -#endif - passert(dicthashtab[dictrehashpos >> HASHTAB_LOBITS]); - } - ehptr = dicthashtab[(dictrehashpos - (dicthashsize/2)) >> HASHTAB_LOBITS] + (dictrehashpos & HASHTAB_MASK); - ehptralt = dicthashtab[dictrehashpos >> HASHTAB_LOBITS] + (dictrehashpos & HASHTAB_MASK); - *ehptralt = NULL; - while ((e=*ehptr)!=NULL) { - hash = e->hashval & mask; - if (hash==dictrehashpos) { - *ehptralt = e; - *ehptr = e->next; - ehptralt = &(e->next); - e->next = NULL; - } else { - ehptr = &(e->next); - } - moved++; - } - dictrehashpos++; - } while (moved= dictrehashpos) { - hash -= dicthashsize/2; - } - } - for (e=dicthashtab[hash>>HASHTAB_LOBITS][hash&HASHTAB_MASK] ; e ; e=e->next) { - if (e->hashval==hashval && e->leng==leng && memcmp((char*)(e->data),(char*)data,leng)==0) { - return e; - } - } - return NULL; -} - -static inline void dict_delete(dictentry *e) { - dictentry **ehptr,*eit; - uint32_t hash; - - if (dicthashsize==0) { - return; - } - hash = (e->hashval) & (dicthashsize-1); - if (dictrehashpos= dictrehashpos) { - hash -= dicthashsize/2; - } - } - ehptr = dicthashtab[hash>>HASHTAB_LOBITS] + (hash&HASHTAB_MASK); - while ((eit=*ehptr)!=NULL) { - if (eit==e) { - *ehptr = e->next; - dicthashelem--; - return; - } - ehptr = &(eit->next); - } - uassert("dictionary element not found in data structure"); -} - -static inline void dict_add(dictentry *e) { - uint16_t i; - uint32_t hash; - - if (dicthashsize==0) { - dicthashsize = dict_calc_hash_size(HASHTAB_SIZEHINT); - dictrehashpos = dicthashsize; - dicthashelem = 0; - for (i=0 ; i>HASHTAB_LOBITS ; i++) { -#ifdef HAVE_MMAP - dicthashtab[i] = mmap(NULL,sizeof(dictentry*)*HASHTAB_LOSIZE,PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE,-1,0); -#else - dicthashtab[i] = malloc(sizeof(dictentry*)*HASHTAB_LOSIZE); -#endif - passert(dicthashtab[i]); - memset(dicthashtab[i],0,sizeof(dictentry*)); - if (dicthashtab[i][0]==NULL) { - memset(dicthashtab[i],0,sizeof(dictentry*)*HASHTAB_LOSIZE); - } else { - for (hash=0 ; hashhashval = dict_hash(e->data,e->leng); - hash = (e->hashval) & (dicthashsize-1); - if (dictrehashpos= dictrehashpos) { - hash -= dicthashsize/2; - } - e->next = dicthashtab[hash>>HASHTAB_LOBITS][hash&HASHTAB_MASK]; - dicthashtab[hash>>HASHTAB_LOBITS][hash&HASHTAB_MASK] = e; - dicthashelem++; - } else { - e->next = dicthashtab[hash>>HASHTAB_LOBITS][hash&HASHTAB_MASK]; - dicthashtab[hash>>HASHTAB_LOBITS][hash&HASHTAB_MASK] = e; - dicthashelem++; - if (dicthashelem>dicthashsize && (dicthashsize>>HASHTAB_LOBITS)value); + return e->value; } #endif