-#ifdef RAW
-#include <raw.h>
-#else
#include <stdio.h>
-#endif
#include <sys/types.h>
+#ifndef MULTICORE
#include <sys/stat.h>
#include <fcntl.h>
+#endif
#include <stdlib.h>
#include <limits.h>
#endif
void * getfirstkey(struct genhashtable *ht) {
- if(ht->list == NULL) {
- return NULL;
- }
+ if(ht->list == NULL) {
+ return NULL;
+ }
return ht->list->src;
}
ht->counter++;
if(ht->counter>ht->currentsize&&ht->currentsize!=INT_MAX) {
/* Expand hashtable */
- long newcurrentsize=(ht->currentsize<(INT_MAX/2))?ht->currentsize*2:INT_MAX;
+ long newcurrentsize=(ht->currentsize<(INT_MAX/2)) ? ht->currentsize*2 : INT_MAX;
long oldcurrentsize=ht->currentsize;
struct genpointerlist **newbins=(struct genpointerlist **) RUNMALLOC(sizeof (struct genpointerlist *)*newcurrentsize);
struct genpointerlist **oldbins=ht->bins;
long j,i;
- for(j=0;j<newcurrentsize;j++) newbins[j]=NULL;
+ for(j=0; j<newcurrentsize; j++) newbins[j]=NULL;
ht->currentsize=newcurrentsize;
- for(i=0;i<oldcurrentsize;i++) {
+ for(i=0; i<oldcurrentsize; i++) {
struct genpointerlist * tmpptr=oldbins[i];
while(tmpptr!=NULL) {
unsigned int hashcode=genhashfunction(ht, tmpptr->src);
return 1;
}
-#ifdef RAW
+#ifdef MULTICORE
int genputtable_I(struct genhashtable *ht, void * key, void * object) {
unsigned int bin=genhashfunction(ht,key);
struct genpointerlist * newptrlist=(struct genpointerlist *) RUNMALLOC_I(sizeof(struct genpointerlist));
ht->counter++;
if(ht->counter>ht->currentsize&&ht->currentsize!=INT_MAX) {
/* Expand hashtable */
- long newcurrentsize=(ht->currentsize<(INT_MAX/2))?ht->currentsize*2:INT_MAX;
+ long newcurrentsize=(ht->currentsize<(INT_MAX/2)) ? ht->currentsize*2 : INT_MAX;
long oldcurrentsize=ht->currentsize;
struct genpointerlist **newbins=(struct genpointerlist **) RUNMALLOC_I(sizeof (struct genpointerlist *)*newcurrentsize);
struct genpointerlist **oldbins=ht->bins;
long j,i;
- for(j=0;j<newcurrentsize;j++) newbins[j]=NULL;
+ for(j=0; j<newcurrentsize; j++) newbins[j]=NULL;
ht->currentsize=newcurrentsize;
- for(i=0;i<oldcurrentsize;i++) {
+ for(i=0; i<oldcurrentsize; i++) {
struct genpointerlist * tmpptr=oldbins[i];
while(tmpptr!=NULL) {
unsigned int hashcode=genhashfunction(ht, tmpptr->src);
void genrehash(struct genhashtable * ht) {
struct genpointerlist **newbins=(struct genpointerlist **) RUNMALLOC(sizeof (struct genpointerlist *)*ht->currentsize);
struct genpointerlist **oldbins=ht->bins;
- long j,i;
+ long i;
- for(i=0;i<ht->currentsize;i++) {
+ for(i=0; i<ht->currentsize; i++) {
struct genpointerlist * tmpptr=oldbins[i];
while(tmpptr!=NULL) {
unsigned int hashcode=genhashfunction(ht, tmpptr->src);
return ptr->object;
ptr=ptr->next;
}
-#ifndef RAW
+#ifndef MULTICORE
printf("XXXXXXXXX: COULDN'T FIND ENTRY FOR KEY %p\n",key);
#endif
return NULL;
while(ptr!=NULL) {
if (((ht->comp_function==NULL)&&(ptr->src==key))||((ht->comp_function!=NULL)&&(*ht->comp_function)(ptr->src,key)))
if (ptr->inext!=NULL) {
- return ptr->inext->src;
+ return ptr->inext->src;
} else
- return NULL;
+ return NULL;
ptr=ptr->next;
}
-#ifndef RAW
+#ifndef MULTICORE
printf("XXXXXXXXX: COULDN'T FIND ENTRY FOR KEY %p...\n Likely concurrent removal--bad user!!!\n",key);
#endif
return NULL;
void genfreekey(struct genhashtable *ht, void * key) {
struct genpointerlist * ptr=ht->bins[genhashfunction(ht,key)];
-
+
if (((ht->comp_function==NULL)&&(ptr->src==key))||((ht->comp_function!=NULL)&&(*ht->comp_function)(ptr->src,key))) {
ht->bins[genhashfunction(ht,key)]=ptr->next;
ptr->iprev->inext=ptr->inext;
if (ptr->inext!=NULL)
ptr->inext->iprev=ptr->iprev;
-
+
RUNFREE(ptr);
ht->counter--;
return;
struct genpointerlist *tmpptr=ptr->next;
ptr->next=tmpptr->next;
if (tmpptr==ht->list)
- ht->list=tmpptr->inext;
+ ht->list=tmpptr->inext;
if (tmpptr==ht->last)
- ht->last=tmpptr->iprev;
+ ht->last=tmpptr->iprev;
if (tmpptr->iprev!=NULL)
- tmpptr->iprev->inext=tmpptr->inext;
+ tmpptr->iprev->inext=tmpptr->inext;
if (tmpptr->inext!=NULL)
- tmpptr->inext->iprev=tmpptr->iprev;
+ tmpptr->inext->iprev=tmpptr->iprev;
RUNFREE(tmpptr);
ht->counter--;
return;
}
ptr=ptr->next;
}
-#ifndef RAW
+#ifndef MULTICORE
printf("XXXXXXXXX: COULDN'T FIND ENTRY FOR KEY %p\n",key);
#endif
}
struct genpointerlist **gpl;
int i;
-#ifdef RAWDEBUG
- raw_test_pass(0xf000);
-#endif
-
gpl=(struct genpointerlist **) RUNMALLOC(sizeof(struct genpointerlist *)*geninitialnumbins);
-#ifdef RAWDEBUG
- raw_test_pass(0xf001);
-#endif
- for(i=0;i<geninitialnumbins;i++) {
+ for(i=0; i<geninitialnumbins; i++) {
gpl[i]=NULL;
}
-#ifdef RAWDEBUG
- raw_test_pass(0xf002);
-#endif
ght=(struct genhashtable *) RUNMALLOC(sizeof(struct genhashtable));
-#ifdef RAWDEBUG
- raw_test_pass(0xf003);
-#endif
ght->hash_function=hash_function;
ght->comp_function=comp_function;
ght->currentsize=geninitialnumbins;
ght->counter=0;
ght->list=NULL;
ght->last=NULL;
-#ifdef RAWDEBUG
- raw_test_pass(0xf004);
-#endif
return ght;
}
void genfreehashtable(struct genhashtable * ht) {
int i;
- for (i=0;i<ht->currentsize;i++) {
+ for (i=0; i<ht->currentsize; i++) {
if (ht->bins[i]!=NULL) {
struct genpointerlist *genptr=ht->bins[i];
while(genptr!=NULL) {
- struct genpointerlist *tmpptr=genptr->next;
- RUNFREE(genptr);
- genptr=tmpptr;
+ struct genpointerlist *tmpptr=genptr->next;
+ RUNFREE(genptr);
+ genptr=tmpptr;
}
}
}
if(curr->inext!=NULL)
it->ptr=curr->inext;
else
- it->finished=1; /* change offsetting scheme */
+ it->finished=1; /* change offsetting scheme */
return curr->src;
}