pike.git / src / stralloc.c

version» Context lines:

pike.git/src/stralloc.c:18:      #include <errno.h>   #include <float.h>   #include <ctype.h>   #include <math.h>      #ifndef HUGE   #define HUGE HUGE_VAL   #endif /*!HUGE*/    - RCSID("$Id: stralloc.c,v 1.92 2000/08/10 08:41:30 grubba Exp $"); + RCSID("$Id: stralloc.c,v 1.93 2000/08/10 17:57:04 grubba Exp $");      #define BEGIN_HASH_SIZE 997   #define MAX_AVG_LINK_LENGTH 3      /* Experimental dynamic hash length */   #ifndef HASH_PREFIX   static unsigned int HASH_PREFIX=64;   static unsigned int need_more_hash_prefix=0;   #endif   
pike.git/src/stralloc.c:40:   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 ***/         #define StrHash(s,len) low_do_hash(s,len,0)    - static unsigned int low_do_hash(const void *s, int len, int size_shift) + static unsigned int low_do_hash(const void *s, ptrdiff_t len, int size_shift)   {    full_hash_value=hashmem(s,len<<size_shift,HASH_PREFIX<<size_shift);    return full_hash_value % htable_size;   }      static INLINE unsigned int do_hash(struct pike_string *s)   {    return low_do_hash(s->str, s->len, s->size_shift);   }       - static INLINE int find_magnitude1(const unsigned INT16 *s, int len) + static INLINE int find_magnitude1(const unsigned INT16 *s, ptrdiff_t len)   {    while(--len>=0)    if(s[len]>=256)    return 1;    return 0;   }    - static INLINE int find_magnitude2(const unsigned INT32 *s, int len) + static INLINE int find_magnitude2(const unsigned INT32 *s, ptrdiff_t len)   {    while(--len>=0)    {    if(s[len]>=256)    {    do    {    if(s[len]>=65536)    return 2;    }while(--len>=0);
pike.git/src/stralloc.c:154:         CONVERT(0,1)   CONVERT(0,2)   CONVERT(1,0)   CONVERT(1,2)   CONVERT(2,0)   CONVERT(2,1)       - PMOD_EXPORT int generic_compare_strings(const void *a,int alen, int asize, -  const void *b,int blen, int bsize) + PMOD_EXPORT int generic_compare_strings(const void *a, ptrdiff_t alen, int asize, +  const void *b, ptrdiff_t blen, int bsize)   {   #define TWO_SIZES(X,Y) (((X)<<2)+(Y))    if(alen != blen) return 0;    if(asize==bsize)    {    return !MEMCMP(a,b,alen<<asize);    }else{    INT32 pos;    for(pos=0;pos< alen ;pos++)    if(generic_extract(a,asize,pos) != generic_extract(b,bsize,pos))    return 0;    return 1;    }   }         PMOD_EXPORT void generic_memcpy(PCHARP to,    PCHARP from, -  int len) +  ptrdiff_t len)   {   #ifdef PIKE_DEBUG    if(len<0)    fatal("Cannot copy %d bytes!\n",len);   #endif       switch(TWO_SIZES(from.shift,to.shift))    {    case TWO_SIZES(0,0):    convert_0_to_0((p_wchar0 *)to.ptr,(p_wchar0 *)from.ptr,len);
pike.git/src/stralloc.c:278:    return index_shared_string(s,s->len);   }   #else   #define locate_problem(X)   #endif      /* Find a string in the shared string table.    * This assumes that the string is minimized!!!!    */   static struct pike_string *internal_findstring(const char *s, -  int len, +  ptrdiff_t len,    int size_shift,    int h)   {    struct pike_string *curr,**prev, **base;   #ifndef HASH_PREFIX    unsigned int depth=0;   #endif       for(base = prev = base_table + h;( curr=*prev ); prev=&curr->next)    {
pike.git/src/stralloc.c:437:    if(num_strings > MAX_AVG_LINK_LENGTH * htable_size)    rehash();      #ifndef HASH_PREFIX    /* These heuruistics might require tuning! /Hubbe */    if(need_more_hash_prefix > ( htable_size >> 4))    {    /* This could in theory have a pretty ugly complexity */    /* /Hubbe    */ -  unsigned INT32 save_full_hash_value=full_hash_value; +  size_t save_full_hash_value = full_hash_value;       need_more_hash_prefix=0;    HASH_PREFIX=HASH_PREFIX*2;   /* fprintf(stderr,"Doubling HASH_PREFIX to %d and rehashing\n",HASH_PREFIX); */       for(h=0;h<htable_size;h++)    {    struct pike_string *tmp=base_table[h];    base_table[h]=0;    while(tmp)    { -  unsigned int h2; +  size_t h2;    struct pike_string *tmp2=tmp; /* First unlink */    tmp=tmp2->next;       h2=do_hash(tmp2); /* compute new hash value */    tmp2->hval=full_hash_value;       tmp2->next=base_table[h2]; /* and re-hash */    base_table[h2]=tmp2;    }    }
pike.git/src/stralloc.c:486:    low_set_index(t,len,0);    return t;   }      /*    * This function assumes that the shift size is already the minimum it    * can be.    */   PMOD_EXPORT struct pike_string *low_end_shared_string(struct pike_string *s)   { -  int len,h; +  ptrdiff_t len, h;    struct pike_string *s2;    -  len=s->len; -  h=do_hash(s); -  s2=internal_findstring(s->str,len,s->size_shift,h); +  len = s->len; +  h = do_hash(s); +  s2 = internal_findstring(s->str,len,s->size_shift,h);   #ifdef PIKE_DEBUG    if(s2==s)    fatal("end_shared_string called twice! (or something like that)\n");   #endif       if(s2)    {    free((char *)s);    s=s2;    }else{