pike.git / src / hashtable.c

version» Context lines:

pike.git/src/hashtable.c:1: - /*\ - ||| This file a part of Pike, and is copyright by Fredrik Hubinette - ||| Pike is distributed as GPL (General Public License) - ||| See the files COPYING and DISCLAIMER for more information. - \*/ - /**/ + /* + || This file is part of Pike. For copyright information see COPYRIGHT. + || Pike is distributed under GPL, LGPL and MPL. See the file COPYING + || for more information. + */ +    #include "global.h"   #include "hashtable.h"   #include "stralloc.h"   #include "stuff.h"   #include "pike_error.h"    - RCSID("$Id: hashtable.c,v 1.8 2000/12/01 08:09:47 hubbe Exp $"); -  +    static size_t gobble(struct pike_string *s)   {    size_t i;    i=my_hash_string(s);    i+=i >> 3;    i+=i >> 7;    i+=i >> 12;    return i;   }   
pike.git/src/hashtable.c:77:      /*    * rehash - ugh    */   struct hash_table *hash_rehash(struct hash_table *h,int size)   {    struct hash_table *new;    int e;      #ifdef PIKE_DEBUG -  if( 1 << my_log2(size) != size) -  fatal("Size is not a power of two!\n"); +  if (size & (size-1)) +  Pike_fatal("Size is not a power of two! Size: 0x%08x\n", size);   #endif       new=(struct hash_table *)calloc(1,sizeof(struct hash_table)+    (size-1)*sizeof(struct hash_entry *));    new->mask = size - 1;    new->entries = h->entries;       for(e=0; e<=h->mask; e++)    rehash_list_backwards(new,h->htable[e]);   
pike.git/src/hashtable.c:135:    {    *prev = e->next;    h->entries--;    if(h->mask > NEW_HASHTABLE_SIZE &&    h->entries < AVERAGE_HASH_LENGTH / 2 * h->mask)    h=hash_rehash(h,(h->mask+1) / 2);    return h;    }    }   #ifdef PIKE_DEBUG -  fatal("hash_entry not in hashtable\n"); +  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++)    {