//int keyto = ((unsigned INTPTR)key) % (tbl->size);
//ptr=&tbl->table[keyto];
ptr=&tbl->table[(((unsigned INTPTR)key)&tbl->mask)>>6];
- //printf("%x \n", (((unsigned INTPTR)key)&tbl->mask)>>6); // TODO
if(ptr->key==0) {
// the first time insert a value for the key
//int keyto = ((unsigned INTPTR)key) % (tbl->size);
//ptr=&tbl->table[keyto];
ptr=&tbl->table[(((unsigned INTPTR)key)&tbl->mask)>>6];
- //printf("%x \n", (((unsigned INTPTR)key)&tbl->mask)>>6); // TODO
if(ptr->key==0) {
// the first time insert a value for the key
ctable->threshold=size*loadfactor;
ctable->mask = (size << 6)-1;
- ctable->list = NULL;
+ //ctable->list = NULL;
ctable->structs = (mgcliststruct_t*)RUNMALLOC(1*sizeof(mgcliststruct_t));
ctable->numelements = 0; // Initial number of elements in the hash
mgchashlistnode_t *ptr = tbl->table;
int i;
- if (tbl->numelements<(tbl->size>>6)) {
+ /*if (tbl->numelements<(tbl->size>>6)) {
mgchashlistnode_t *top=&ptr[tbl->size];
mgchashlistnode_t * list = tbl->list;
while(list != NULL) {
- mgchashlistnode_t * next = list->next;
+ mgchashlistnode_t * next = list->lnext;
if ((list >= ptr) && (list < top)) {
//zero in list
list->key=NULL;
}
list = next;
}
- } else {
+ } else {*/
BAMBOO_MEMSET_WH(tbl->table, '\0', sizeof(mgchashlistnode_t)*tbl->size);
- }
+ //}
// TODO now never release any allocated memory, may need to be changed
mgcliststruct_t * next = tbl->structs;
while(/*tbl->structs->*/next!=NULL) {
// the first time insert a value for the key
ptr->key=key;
ptr->val=val;
+ /*ptr->lnext = tbl->list;
+ tbl->list = ptr;*/
} else { // Insert in the beginning of linked list
mgchashlistnode_t * node;
if (tbl->structs->num<NUMMGCLIST) {
node->val = val;
node->next = ptr->next;
ptr->next = node;
+ /*node->lnext = tbl->list;
+ tbl->list = node;*/
}
}
ctable->threshold=size*loadfactor;
ctable->mask = (size << 6)-1;
- ctable->list = NULL;
+ //ctable->list = NULL;
ctable->structs = (mgcliststruct_t*)RUNMALLOC_I(1*sizeof(mgcliststruct_t));
ctable->numelements = 0; // Initial number of elements in the hash
if(ptr->key==0) {
ptr->key=key;
ptr->val=val;
+ /*ptr->lnext = tbl->list;
+ tbl->list = ptr;*/
return;
} else { // Insert in the beginning of linked list
mgchashlistnode_t * node;
node->val = val;
node->next = ptr->next;
ptr->next = node;
+ /*node->lnext = tbl->list;
+ tbl->list = node;*/
}
}
#endif
tbl->size = newsize;
tbl->threshold = newsize * tbl->loadfactor;
mask = tbl->mask = (newsize << 6) - 1;
+ //tbl->list = NULL;
for(i = 0; i < oldsize; i++) { //Outer loop for each bin in hash table
curr = &ptr[i];
if(tmp->key == 0) {
tmp->key = key;
tmp->val = curr->val;
+ /*tmp->lnext = tbl->list;
+ tbl->list = tmp;*/
} /*
NOTE: Add this case if you change this...
This case currently never happens because of the way things rehash....*/
newnode->val = curr->val;
newnode->next = tmp->next;
tmp->next=newnode;
+ /*newnode->lnext = tbl->list;
+ tbl->list = newnode;*/
}
else {
curr->next=tmp->next;
tmp->next=curr;
+ /*curr->lnext = tbl->list;
+ tbl->list = curr;*/
}
isfirst = 0;
tbl->size = newsize;
tbl->threshold = newsize * tbl->loadfactor;
mask = tbl->mask = (newsize << 6)-1;
+ //tbl->list = NULL;
for(i = 0; i < oldsize; i++) { //Outer loop for each bin in hash table
curr = &ptr[i];
if(tmp->key == 0) {
tmp->key = key;
tmp->val = curr->val;
+ /*tmp->lnext = tbl->list;
+ tbl->list = tmp;*/
} /*
NOTE: Add this case if you change this...
This case currently never happens because of the way things rehash....*/
newnode->val = curr->val;
newnode->next = tmp->next;
tmp->next=newnode;
+ /*newnode->lnext = tbl->list;
+ tbl->list = newnode;*/
} else {
curr->next=tmp->next;
tmp->next=curr;
+ /*curr->lnext = tbl->list;
+ tbl->list = curr;*/
}
isfirst = 0;