This update adds precise garbage collection to the compiler and the runtime.
[IRC.git] / Robust / src / Runtime / GenericHashtable.c
index 86f40e58acc92c319934f3de1b56d79062cf334e..24d9d70cb3eddc620d027679f5712f2690f3f2fd 100755 (executable)
@@ -58,6 +58,26 @@ int hashsize(struct genhashtable *ht) {
   return ht->counter;
 }
 
+void genrehash(struct genhashtable * ht) {
+  /* Expand hashtable */
+  struct genpointerlist **newbins=(struct genpointerlist **) RUNMALLOC(sizeof (struct genpointerlist *)*ht->currentsize);
+  struct genpointerlist **oldbins=ht->bins;
+  long j,i;
+
+  for(i=0;i<ht->currentsize;i++) {
+    struct genpointerlist * tmpptr=oldbins[i];
+    while(tmpptr!=NULL) {
+      int hashcode=genhashfunction(ht, tmpptr->src);
+      struct genpointerlist *nextptr=tmpptr->next;
+      tmpptr->next=newbins[hashcode];
+      newbins[hashcode]=tmpptr;
+      tmpptr=nextptr;
+    }
+  }
+  ht->bins=newbins;
+  RUNFREE(oldbins);
+}
+
 void * gengettable(struct genhashtable *ht, void * key) {
   struct genpointerlist * ptr=ht->bins[genhashfunction(ht,key)];
   while(ptr!=NULL) {