add batch-mode script
[IRC.git] / Robust / src / Runtime / ObjectHash.c
index 1a79be2c5ddaa58c179641c97a186d27f93b1dd2..b0e8d077613866950568467e4e7a36009effd35a 100755 (executable)
@@ -1,9 +1,12 @@
 #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
@@ -22,10 +25,10 @@ struct ObjectHash * noargallocateObjectHash() {
 }
 
 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);
@@ -66,7 +69,6 @@ int ObjectHashremove(struct ObjectHash *thisvar, int key) {
   unsigned int hashkey = (unsigned int)key % thisvar->size;
 
   struct ObjectNode **ptr = &thisvar->bucket[hashkey];
-  int i;
 
   while (*ptr) {
     if ((*ptr)->key == key) {
@@ -74,14 +76,14 @@ int ObjectHashremove(struct ObjectHash *thisvar, int 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);
 
@@ -100,7 +102,7 @@ void ObjectHashrehash(struct ObjectHash * thisvar) {
   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];
@@ -124,12 +126,12 @@ int ObjectHashadd(struct ObjectHash * thisvar,int key, int data, int data2, int
     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;
@@ -166,7 +168,7 @@ int ObjectHashadd(struct ObjectHash * thisvar,int key, int data, int data2, int
   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;
@@ -178,16 +180,16 @@ int ObjectHashadd_I(struct ObjectHash * thisvar,int key, int data, int data2, in
     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;
   }