+#ifdef STM
+void fixobjlist(struct objlist * ptr) {
+ while(ptr!=NULL) {
+ int i;
+ for(i=0;i<ptr->offset;i++) {
+ SENQUEUE(ptr->objs[i], ptr->objs[i]);
+ }
+ ptr=ptr->next;
+ }
+}
+
+void fixtable(chashlistnode_t ** tc_table, chashlistnode_t **tc_list, cliststruct_t **cstr, unsigned int tc_size) {
+ unsigned int mask=(tc_size<<4)-1;
+ chashlistnode_t *node=calloc(tc_size, sizeof(chashlistnode_t));
+ chashlistnode_t *ptr=*tc_table;
+ chashlistnode_t *curr;
+ unsigned int i;
+ unsigned int index;
+ int isfirst;
+ chashlistnode_t *newlist=NULL;
+ for(i=0;i<tc_size;i++) {
+ curr=&ptr[i];
+ isfirst=1;
+ do { //Inner loop to go through linked lists
+ void * key;
+ chashlistnode_t *tmp,*next;
+
+ if ((key=(void *)curr->key) == 0) { //Exit inner loop if there the first element is 0
+ break; //key = val =0 for element if not present within the hash table
+ }
+ SENQUEUE(key, key);
+ if (curr->val>=curr_heapbase&&curr->val<curr_heaptop) {
+ SENQUEUE(curr->val, curr->val);
+ } else {
+ //rewrite transaction cache entry
+ void *vptr=curr->val;
+ int type=((int *)vptr)[0];
+ unsigned INTPTR *pointer=pointerarray[type];
+ if (pointer==0) {
+ //array of primitives - do nothing
+ struct ArrayObject *ao=(struct ArrayObject *) vptr;
+ SENQUEUE((void *)ao->___objlocation___, *((void **)&ao->___objlocation___));
+ } else if (((INTPTR)pointer)==1) {
+ //array of pointers
+ struct ArrayObject *ao=(struct ArrayObject *) vptr;
+ int length=ao->___length___;
+ int i;
+ SENQUEUE((void *)ao->___objlocation___, *((void **)&ao->___objlocation___));
+ for(i=0; i<length; i++) {
+ void *objptr=((void **)(((char *)&ao->___length___)+sizeof(int)))[i];
+ SENQUEUE(objptr, ((void **)(((char *)&ao->___length___)+sizeof(int)))[i]);
+ }
+ } else {
+ INTPTR size=pointer[0];
+ int i;
+ for(i=1; i<=size; i++) {
+ unsigned int offset=pointer[i];
+ void * objptr=*((void **)(((char *)vptr)+offset));
+ SENQUEUE(objptr, *((void **)(((char *)vptr)+offset)));
+ }
+ }
+ }
+
+ next = curr->next;
+ index = (((unsigned INTPTR)key) & mask) >>4;
+
+ curr->key=key;
+ tmp=&node[index];
+ // Insert into the new table
+ if(tmp->key == 0) {
+ tmp->key = curr->key;
+ tmp->val = curr->val;
+ tmp->lnext=newlist;
+ newlist=tmp;
+ } else if (isfirst) {
+ chashlistnode_t *newnode;
+ if ((*cstr)->num<NUMCLIST) {
+ newnode=&(*cstr)->array[(*cstr)->num];
+ (*cstr)->num++;
+ } else {
+ //get new list
+ cliststruct_t *tcl=calloc(1,sizeof(cliststruct_t));
+ tcl->next=*cstr;
+ *cstr=tcl;
+ newnode=&tcl->array[0];
+ tcl->num=1;
+ }
+ newnode->key = curr->key;
+ newnode->val = curr->val;
+ newnode->next = tmp->next;
+ newnode->lnext=newlist;
+ newlist=newnode;
+ tmp->next=newnode;
+ } else {
+ curr->lnext=newlist;
+ newlist=curr;
+ curr->next=tmp->next;
+ tmp->next=curr;
+ }
+ isfirst = 0;
+ curr = next;
+ } while(curr!=NULL);
+ }
+ free(ptr);
+ (*tc_table)=node;
+ (*tc_list)=newlist;
+}
+#endif
+