pike.git / src / stralloc.c

version» Context lines:

pike.git/src/stralloc.c:95:    {    *prev = curr->next;    curr->next = *base;    *base = curr;    return curr; /* pointer to string */    }    }    return 0; /* not found */   }    - struct pike_string *findstring(const char *foo) + struct pike_string *binary_findstring(const char *foo, INT32 l)   { -  int l; -  l=strlen(foo); +     return internal_findstring(foo, l, StrHash(foo,l));   }    -  + struct pike_string *findstring(const char *foo) + { +  return binary_findstring(foo, strlen(foo)); + } +    /*    * find a string that is already shared and move it to the head    * of that list in the hastable    */   static struct pike_string *propagate_shared_string(const struct pike_string *s,int h)   {    struct pike_string *curr, **prev, **base;       for(base = prev = base_table + h;( curr=*prev ); prev=&curr->next)    {
pike.git/src/stralloc.c:141:   }   #endif      /* note that begin_shared_string expects the _exact_ size of the string,    * not the maximum size    */   struct pike_string *begin_shared_string(int len)   {    struct pike_string *t;    t=(struct pike_string *)xalloc(len + sizeof(struct pike_string)); +  t->str[len]=0;    t->len=len;    return t;   }      struct pike_string *end_shared_string(struct pike_string *s)   {    int len,h;    struct pike_string *s2;       len=s->len;    h=StrHash(s->str,len);    s2=internal_findstring(s->str,len,h);       if(s2)    {    free((char *)s);    s=s2;    }else{ -  s->str[len]=0; +     s->refs = 0;    s->next = base_table[h];    base_table[h] = s;    s->hval=full_hash_value;    }    s->refs++;       return s;   }