pike.git / src / stralloc.c

version» Context lines:

pike.git/src/stralloc.c:4:   ||| See the files COPYING and DISCLAIMER for more information.   \*/   #include "global.h"   #include "stralloc.h"   #include "pike_macros.h"   #include "dynamic_buffer.h"   #include "pike_macros.h"   #include "pike_memory.h"   #include "error.h"   #include "gc.h" + #include "stuff.h"      #define BEGIN_HASH_SIZE 997   #define MAX_AVG_LINK_LENGTH 3      unsigned INT32 htable_size=0; -  + static unsigned int hashprimes_entry=0;   static struct pike_string **base_table=0;   static unsigned INT32 full_hash_value;   unsigned INT32 num_strings=0;      /*** Main string hash function ***/   static unsigned int StrHash(const char *s,int len)   {    full_hash_value=hashmem((unsigned char *)s, len, 20);    return full_hash_value % htable_size;   }
pike.git/src/stralloc.c:101:   }      static void rehash(void)   {    int h,old;    struct pike_string **old_base;       old=htable_size;    old_base=base_table;    -  htable_size=htable_size*2 +1; +  htable_size=hashprimes[++hashprimes_entry];    base_table=(struct pike_string **)xalloc(sizeof(struct pike_string *)*htable_size);    MEMSET((char *)base_table,0,sizeof(struct pike_string *)*htable_size);       for(h=0;h<old;h++) rehash_string_backwards(old_base[h]);       if(old_base)    free((char *)old_base);   }      
pike.git/src/stralloc.c:567:    s=tmp+del->len;    }    MEMCPY(r,s,end-s);       return end_shared_string(ret);   }      /*** init/exit memory ***/   void init_shared_string_table(void)   { -  htable_size=BEGIN_HASH_SIZE; +  for(hashprimes_entry;hashprimes[hashprimes_entry]<BEGIN_HASH_SIZE;hashprimes_entry++); +  htable_size=hashprimes[hashprimes_entry];    base_table=(struct pike_string **)xalloc(sizeof(struct pike_string *)*htable_size);    MEMSET((char *)base_table,0,sizeof(struct pike_string *)*htable_size);   }      void cleanup_shared_string_table(void)   {    unsigned INT32 e;    struct pike_string *s,*next;    for(e=0;e<htable_size;e++)    {