pike.git / src / hashtable.c

version» Context lines:

pike.git/src/hashtable.c:50:    if(!n) return;    rehash_list_backwards(h,n->next);    base=h->htable + (gobble(n->s) & h->mask);    n->next = *base;    *base=n;   }      /*    * create a new, empty hashable   */ - struct hash_table *create_hash_table(void) + static struct hash_table *create_hash_table(void)   {    struct hash_table *new;    new=calloc(1, sizeof(struct hash_table)+    (NEW_HASHTABLE_SIZE-1)*sizeof(struct hash_entry *));    new->entries=0;    new->mask=NEW_HASHTABLE_SIZE-1;    return new;   }      /*    * rehash - ugh    */ - struct hash_table *hash_rehash(struct hash_table *h,int size) + static struct hash_table *hash_rehash(struct hash_table *h,int size)   {    struct hash_table *new;    int e;      #ifdef PIKE_DEBUG    if (size & (size-1))    Pike_fatal("Size is not a power of two! Size: 0x%08x\n", size);   #endif       new=calloc(1, sizeof(struct hash_table)+
pike.git/src/hashtable.c:132:    h=hash_rehash(h,(h->mask+1) / 2);    return h;    }    }   #ifdef PIKE_DEBUG    Pike_fatal("hash_entry not in hashtable\n");   #endif    return h;   }    - void map_hashtable(struct hash_table *h, void (*fun)(struct hash_entry *)) - { -  INT32 e; -  struct hash_entry *i, *n; -  for(e=0;e<=h->mask;e++) -  { -  for(i=h->htable[e];i;i=n) -  { -  n=i->next; -  fun(i); -  } -  } - } -  +    void free_hashtable(struct hash_table *h,    void (*free_entry)(struct hash_entry *))   {    INT32 e;    struct hash_entry *i, *n;    for(e=0;e<=h->mask;e++)    {    for(i=h->htable[e];i;i=n)    {    n=i->next;    free_string(i->s);    if(free_entry)    free_entry(i);    else    free(i);    }    }    free(h);   }