pike.git / src / stralloc.c

version» Context lines:

pike.git/src/stralloc.c:16:      #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.62 1999/09/02 04:40:49 hubbe Exp $"); + RCSID("$Id: stralloc.c,v 1.63 1999/09/06 12:31:31 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=32; - static int need_more_hash_prefix=0; + static unsigned int need_more_hash_prefix=0;   #endif      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 ***/   
pike.git/src/stralloc.c:271:    return (s->hval % htable_size) != do_hash(s);   }   static int improper_zero_termination(struct pike_string *s)   {    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!!!! - \*/ + /* 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,    int size_shift,    int h)   {    struct pike_string *curr,**prev, **base;   #ifndef HASH_PREFIX    unsigned int depth=0;   #endif   
pike.git/src/stralloc.c:311:    curr->next = *base;    *base = curr;    return curr; /* pointer to string */    }   #ifndef HASH_PREFIX    depth++;   #endif    }   #ifndef HASH_PREFIX    /* These heuruistics might require tuning! /Hubbe */ -  if(depth > HASH_PREFIX && HASH_PREFIX<len) +  if((depth > HASH_PREFIX) && (HASH_PREFIX < (unsigned int)len))    {    need_more_hash_prefix++;   /* fprintf(stderr,"depth=%d num_strings=%d need_more_hash_prefix=%d HASH_PREFIX=%d\n",depth,num_strings,need_more_hash_prefix,HASH_PREFIX); */    }else{    if(need_more_hash_prefix)    need_more_hash_prefix--;    }   #endif    return 0; /* not found */   }
pike.git/src/stralloc.c:415: Inside #if defined(PIKE_DEBUG)
   if(d_flag>10)    verify_shared_strings_tables();   #endif    t=(struct pike_string *)xalloc(len + sizeof(struct pike_string));    t->str[len]=0;    t->len=len;    t->size_shift=0;    return t;   }    - static void link_pike_string(struct pike_string *s, int h) + static void link_pike_string(struct pike_string *s, unsigned int h)   {    s->refs = 0;    s->next = base_table[h];    base_table[h] = s;    s->hval=full_hash_value;    num_strings++;    if(num_strings > MAX_AVG_LINK_LENGTH * htable_size)    rehash();      #ifndef HASH_PREFIX
pike.git/src/stralloc.c:444: Inside #if undefined(HASH_PREFIX)
   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)    { -  int h2; +  unsigned int 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:1236:    }    }    }          /* We now know that the string has the right character size */    if(a->refs==1)    {    /* One ref - destructive mode */    -  if(index>=HASH_PREFIX && index<a->len-8) +  if((((unsigned int)index) >= HASH_PREFIX) && (index < a->len-8))    {    /* Doesn't change hash value - sneak it in there */    low_set_index(a,index,c);    return a;    }else{    unlink_pike_string(a);    low_set_index(a,index,c);    return end_shared_string(a);    }    }else{