int ddb_update (const dict_t *config, const char *startup, const char *name, compat_flags_t flags) { int result = RET_OK; const char *disc_db = dict_lookup (config, CONFIG_DISC_DATABASE_FILE); dict_t *list = dict_restore (NULL, disc_db); if (list != NULL) { char tmp[500]; compat_flags_t dummy; result = ddb_lookup (config, startup, tmp, &dummy); if (result != RET_DDB_INCOMPATIBLE) { /* do not overwrite entries, marked as incompatible */ sprintf (tmp, "%s;0x%02x", name, flags); (void) dict_put (list, startup, tmp); result = dict_store (list, disc_db); } dict_free (list), list = NULL; } else result = RET_NO_DISC_DB; return (result); }
int main(){ int collisions[15]; int* m[3] ={hash,refHash,h3} ; memset(collisions,0,sizeof(int)*15); int lengths[]={10,100,1000,10000,100000,1000000}; //int lengths[]={10,100}; int llen = 4; Dict * dict; printf("before loop\n"); int fcounter=0; while(fcounter<3){ int (*h)(int,int)=0; void* v = m[fcounter]; int i=0; h=v; while (i<llen){ int j=0; srand(10); dict = (Dict*) malloc(lengths[i]*sizeof(Dict)); memset(dict, 0, lengths[i]*sizeof(Dict)); printf("before loop\n"); while(j<lengths[i]){ int r = malloc(50); if(dict_get(dict,v,r,lengths[i])==0){ dict_store(dict,v,r,&r,lengths[i]); }else{ dict_storeN(dict,v,r,&r,lengths[i]); collisions[fcounter*llen+i]+=1; } j++; } free(dict); i++; } fcounter++; } { int i=0; for(i=0;i<3*llen;i++){ printf("function %d num of el = collisions %d = %d\n",i/llen,lengths[i%llen],collisions[i]); } } /* DictMLL d[100]; int key; void * val=&key; int i=0; memset(d,0,sizeof(DictMLL)*100); dict_storell(d,hash,key,val,100); dict_storell(d,hash,key|0x80000000,val+1,100); void * v1 = dict_getll(d,hash,key|0x80000000,100); void * v2 = dict_getll(d,hash,key,100); printf("key=%p|val=%p\nkey=%p|val=%p\n",key|0x80000000,v1,key,v2); while(i<100){ ll * l; printf("\n"); printf("%d = %p",i,d[i].val); if(l=d[i].next){ printLL(l); } i++; } */ printf("\n"); }