#include "ObjectHash.h"
-#ifdef RAW
-#include <raw.h>
+#ifdef MULTICORE
+#include "methodheaders.h"
+#include "runtime_arch.h"
+#include "multicoreruntime.h"
#else
#include <stdio.h>
#endif
+
#ifdef DMALLOC
#include "dmalloc.h"
#endif
}
struct ObjectHash * allocateObjectHash(int size) {
- struct ObjectHash *thisvar; //=(struct ObjectHash *)RUNMALLOC(sizeof(struct ObjectHash));
+ struct ObjectHash *thisvar;
if (size <= 0) {
-#ifdef RAW
- raw_test_done(0xc001);
+#ifdef MULTICORE
+ BAMBOO_EXIT();
#else
printf("Negative Hashtable size Exception\n");
exit(-1);
unsigned int hashkey = (unsigned int)key % thisvar->size;
struct ObjectNode **ptr = &thisvar->bucket[hashkey];
- int i;
while (*ptr) {
if ((*ptr)->key == key) {
*ptr=(*ptr)->next;
if (toremove->lprev!=NULL) {
- toremove->lprev->lnext=toremove->lnext;
+ toremove->lprev->lnext=toremove->lnext;
} else {
- thisvar->listhead=toremove->lnext;
+ thisvar->listhead=toremove->lnext;
}
if (toremove->lnext!=NULL) {
- toremove->lnext->lprev=toremove->lprev;
+ toremove->lnext->lprev=toremove->lprev;
} else {
- thisvar->listtail=toremove->lprev;
+ thisvar->listtail=toremove->lprev;
}
RUNFREE(toremove);
int i;
for(i=thisvar->size-1; i>=0; i--) {
struct ObjectNode *ptr;
- for(ptr=thisvar->bucket[i]; ptr!=NULL;) {
+ for(ptr=thisvar->bucket[i]; ptr!=NULL; ) {
struct ObjectNode * nextptr=ptr->next;
unsigned int newhashkey=(unsigned int)ptr->key % newsize;
ptr->next=newbucket[newhashkey];
int i;
for(i=thisvar->size-1; i>=0; i--) {
struct ObjectNode *ptr;
- for(ptr=thisvar->bucket[i]; ptr!=NULL;) {
- struct ObjectNode * nextptr=ptr->next;
- unsigned int newhashkey=(unsigned int)ptr->key % newsize;
- ptr->next=newbucket[newhashkey];
- newbucket[newhashkey]=ptr;
- ptr=nextptr;
+ for(ptr=thisvar->bucket[i]; ptr!=NULL; ) {
+ struct ObjectNode * nextptr=ptr->next;
+ unsigned int newhashkey=(unsigned int)ptr->key % newsize;
+ ptr->next=newbucket[newhashkey];
+ newbucket[newhashkey]=ptr;
+ ptr=nextptr;
}
}
thisvar->size=newsize;
return 1;
}
-#ifdef RAW
+#ifdef MULTICORE
int ObjectHashadd_I(struct ObjectHash * thisvar,int key, int data, int data2, int data3, int data4) {
/* Rehash code */
unsigned int hashkey;
int i;
for(i=thisvar->size-1; i>=0; i--) {
struct ObjectNode *ptr;
- for(ptr=thisvar->bucket[i]; ptr!=NULL;) {
- struct ObjectNode * nextptr=ptr->next;
- unsigned int newhashkey=(unsigned int)ptr->key % newsize;
- ptr->next=newbucket[newhashkey];
- newbucket[newhashkey]=ptr;
- ptr=nextptr;
+ for(ptr=thisvar->bucket[i]; ptr!=NULL; ) {
+ struct ObjectNode * nextptr=ptr->next;
+ unsigned int newhashkey=(unsigned int)ptr->key % newsize;
+ ptr->next=newbucket[newhashkey];
+ newbucket[newhashkey]=ptr;
+ ptr=nextptr;
}
}
thisvar->size=newsize;
- RUNFREE(thisvar->bucket);
+ RUNFREE_I(thisvar->bucket);
thisvar->bucket=newbucket;
}