pike.git / src / stralloc.c

version» Context lines:

pike.git/src/stralloc.c:1:   /*   || 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. - || $Id: stralloc.c,v 1.201 2005/11/03 16:19:50 grubba Exp $ + || $Id: stralloc.c,v 1.202 2005/11/05 15:28:00 grubba Exp $   */      #include "global.h"   #include "stralloc.h"   #include "pike_macros.h"   #include "dynamic_buffer.h"   #include "pike_macros.h"   #include "pike_memory.h"   #include "pike_error.h"   #include "gc.h"
pike.git/src/stralloc.c:854:   {    struct pike_string *s;    ptrdiff_t h = StrHash(str, len);       s = internal_findstring(str,len,0,h);    if (!s)    {    s=begin_shared_string(len);    MEMCPY(s->str, str, len);    link_pike_string(s, h); +  } else { +  add_ref(s);    }    -  add_ref(s); -  +     return s;   }      PMOD_EXPORT struct pike_string * debug_make_shared_binary_pcharp(const PCHARP str,size_t len)   {    switch(str.shift)    {    case 0:    return make_shared_binary_string((char *)(str.ptr), len);    case 1:
pike.git/src/stralloc.c:909:    }       h=low_do_hash(str, len, 1);       s = internal_findstring((char *)str,len,1,h);    if (!s)    {    s=begin_wide_shared_string(len,1);    MEMCPY(s->str, str, len<<1);    link_pike_string(s, h); +  } else { +  add_ref(s);    }    -  add_ref(s); -  +     return s;   }      PMOD_EXPORT struct pike_string * debug_make_shared_binary_string2(const p_wchar2 *str,size_t len)   {    struct pike_string *s;    ptrdiff_t h;       switch(find_magnitude2(str,len))    {
pike.git/src/stralloc.c:944:    }       h=low_do_hash(str, len, 2);       s = internal_findstring((char *)str,len,2,h);    if (!s)    {    s=begin_wide_shared_string(len,2);    MEMCPY(s->str, str, len<<2);    link_pike_string(s, h); +  } else { +  add_ref(s);    }    -  add_ref(s); -  +     return s;   }      PMOD_EXPORT struct pike_string *debug_make_shared_string(const char *str)   {    return make_shared_binary_string(str, strlen(str));   }      PMOD_EXPORT struct pike_string *debug_make_shared_string0(const p_wchar0 *str)   {
pike.git/src/stralloc.c:1692:    }   #endif    /* Doesn't change hash value - sneak it in there */    old = internal_findstring(a->str, a->len, a->size_shift, a->hval);    if (old) {    /* The new string is equal to some old string. */    free_string(a);    add_ref(a = old);    } else {    link_pike_string(a, a->hval); -  add_ref(a); +     }    }else{    a = end_shared_string(a);    }    return a;    }else{    struct pike_string *r;    r=begin_wide_shared_string(a->len,a->size_shift);    MEMCPY(r->str, a->str, a->len << a->size_shift);    low_set_index(r,index,c);
pike.git/src/stralloc.c:1827:   {    struct pike_string *ret;    char *s,*tmp,*end;    PCHARP r;    int shift;    SearchMojt mojt;    replace_searchfunc f = (replace_searchfunc)0;       if(!str->len)    { -  add_ref(str); -  return str; +  add_ref(empty_pike_string); +  return empty_pike_string;    }       shift=MAXIMUM(str->size_shift,to->size_shift);       if(!del->len)    {    int e,pos;    ret=begin_wide_shared_string(str->len + to->len * (str->len -1),shift);    low_set_index(ret,0,index_shared_string(str,0));    for(pos=e=1;e<str->len;e++)