pike.git / src / stralloc.c

version» Context lines:

pike.git/src/stralloc.c:241:    return 0; \    }      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, 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, + void generic_memcpy(PCHARP to,    PCHARP from,    ptrdiff_t len)   {   #ifdef PIKE_DEBUG    if(len<0)    Pike_fatal("Cannot copy %ld bytes!\n",    DO_NOT_WARN((long)len));   #endif       switch(TWO_SIZES(from.shift,to.shift))
pike.git/src/stralloc.c:761:   {    if (!(s->flags & STRING_NOT_HASHED)) return;    s->hval=do_hash(s);    s->flags &= ~STRING_NOT_HASHED;   }      /*    * 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) + struct pike_string *low_end_shared_string(struct pike_string *s)   {    ptrdiff_t len;    size_t h=0;    struct pike_string *s2;      #ifdef PIKE_DEBUG    if (d_flag) {    switch (s->size_shift) {    case 0:    break;
pike.git/src/stralloc.c:866:    s=s2;    }    break;       case 0: break;    }       return low_end_shared_string(s);   }    + #if 0   PMOD_EXPORT struct pike_string *defer_end_string(struct pike_string *s)   {   #ifdef STRING_DEFER_THRESHOLD    if (s->len > STRING_DEFER_THRESHOLD) {    return s;    }   #endif    return end_shared_string(s);   } -  + #endif      PMOD_EXPORT struct pike_string *end_and_resize_shared_string(struct pike_string *str, ptrdiff_t len)   {    struct pike_string *tmp;   #ifdef PIKE_DEBUG    if(len > str->len)    Pike_fatal("Cannot extend string here!\n");   #endif    if( (str->len <= SHORT_STRING_THRESHOLD) ||    ((len > SHORT_STRING_THRESHOLD) && (str->len <= (len<<1))) )
pike.git/src/stralloc.c:1038:      PMOD_EXPORT struct pike_string *debug_make_shared_string2(const p_wchar2 *str)   {    INT32 len;    for(len=0;str[len];len++);    return debug_make_shared_binary_string2(str,len);   }      /*** Free strings ***/    - PMOD_EXPORT void unlink_pike_string(struct pike_string *s) + static void unlink_pike_string(struct pike_string *s)   {    size_t h;    LOCK_BUCKET(s->hval);    h= HMODULO(s->hval);    propagate_shared_string(s,h);   #ifdef PIKE_DEBUG    if (base_table[h] != s) {    Pike_fatal("propagate_shared_string() failed. Probably got bogus pike_string.\n");    }   #endif /* PIKE_DEBUG */
pike.git/src/stralloc.c:1101:    }   #endif    if (!(s->flags & STRING_NOT_SHARED))    unlink_pike_string(s);    if (s->flags & STRING_CLEAR_ON_EXIT)    MEMSET(s->str, 0, s->len<<s->size_shift);    free_unlinked_pike_string(s);    GC_FREE_SIMPLE_BLOCK(s);   }    - PMOD_EXPORT void do_really_free_string(struct pike_string *s) + void do_really_free_string(struct pike_string *s)   {    if (s)    really_free_string(s);   }      PMOD_EXPORT void debug_free_string(struct pike_string *s)   {    if(!sub_ref(s))    really_free_string(s);   }
pike.git/src/stralloc.c:1287: Inside #if defined(PIKE_DEBUG)
   Pike_fatal("Shared string table is cyclic.\n");    h=0;    }    }    UNLOCK_BUCKET(e);    }    if(num != num_strings)    Pike_fatal("Num strings is wrong %d!=%d\n",num,num_strings);   }    - PMOD_EXPORT int safe_debug_findstring(struct pike_string *foo) + int safe_debug_findstring(struct pike_string *foo)   {    unsigned INT32 e;    if(!base_table) return 0;    for(e=0;e<htable_size;e++)    {    struct pike_string *p;    LOCK_BUCKET(e);    for(p=base_table[e];p;p=p->next)    {    if(p==foo)    {    UNLOCK_BUCKET(e);    return 1;    }    }    UNLOCK_BUCKET(e);    }    return 0;   }    - PMOD_EXPORT struct pike_string *debug_findstring(const struct pike_string *foo) + struct pike_string *debug_findstring(const struct pike_string *foo)   {    struct pike_string *tmp;    tmp=propagate_shared_string(foo, HMODULO(foo->hval));      #if 0    if(!tmp)    {    unsigned INT32 e;    struct pike_string *tmp2;    fprintf(stderr,"String %p %ld %ld %s\n",
pike.git/src/stralloc.c:1436:    tmp=MEMCMP(a, b, alen);    if(tmp) return tmp;    return -1;    }else{    return MEMCMP(a, b, alen);    }   }         /* does not take locale into account */ - PMOD_EXPORT ptrdiff_t generic_quick_binary_strcmp(const char *a, + ptrdiff_t generic_quick_binary_strcmp(const char *a,    ptrdiff_t alen, int asize,    const char *b,    ptrdiff_t blen, int bsize)   {    if(!asize && !bsize)    {    int tmp;    /* FIXME: Does MEMCMP() guarantee that the characters    * are compared as unsigned?    * /grubba 2006-03-11
pike.git/src/stralloc.c:1482:    }   }      /* Does not take locale into account    *    * Similar to (and could be used in place of) generic_quick_binary_strcmp(),    * but returns +/- (offset + 1) to the first difference beween the strings.    *    * This can be used by eg replace_many() to speed up the comparisons.    */ - PMOD_EXPORT ptrdiff_t generic_find_binary_prefix(const char *a, + ptrdiff_t generic_find_binary_prefix(const char *a,    ptrdiff_t alen, int asize,    const char *b,    ptrdiff_t blen, int bsize)   {    ptrdiff_t pos;    ptrdiff_t len = MINIMUM(alen, blen);    switch(TWO_SIZES(asize, bsize)) {   #define CASE(AZ, BZ) \    case TWO_SIZES(AZ, BZ): { \    PIKE_CONCAT(p_wchar, AZ) *a_arr = \
pike.git/src/stralloc.c:1639:    }    free_string(a);    }       r->len=size;    low_set_index(r,size,0);    return r;   }      /* Returns an unlinked string ready for end_shared_string */ - PMOD_EXPORT struct pike_string *realloc_shared_string(struct pike_string *a, + static struct pike_string *realloc_shared_string(struct pike_string *a,    ptrdiff_t size)   {    struct pike_string *r;    if(a->refs==1)    {    unlink_pike_string(a);    return realloc_unlinked_string(a, size);    }else{    r=begin_wide_shared_string(size,a->size_shift);    MEMCPY(r->str, a->str, a->len<<a->size_shift);    free_string(a);    return r;    }   }    - PMOD_EXPORT struct pike_string *new_realloc_shared_string(struct pike_string *a, INT32 size, int shift) + struct pike_string *new_realloc_shared_string(struct pike_string *a, INT32 size, int shift)   {    struct pike_string *r;    if(shift == a->size_shift) return realloc_shared_string(a,size);       r=begin_wide_shared_string(size,shift);    pike_string_cpy(MKPCHARP_STR(r),a);    free_string(a);    return r;   }         /* Modify one index in a shared string    * Not suitable for building new strings or changing multiple characters    * within a string!    *    * Phew, this function become complicated when I inserted magic for wide    * characters...    */ - PMOD_EXPORT struct pike_string *modify_shared_string(struct pike_string *a, + struct pike_string *modify_shared_string(struct pike_string *a,    INT32 index,    INT32 c)   {    INT32 old_value;   #ifdef PIKE_DEBUG    if(index<0 || index>=a->len)    Pike_fatal("Index out of range in modify_shared_string()\n");   #endif      
pike.git/src/stralloc.c:3118:    low_set_index(s->s,s->s->len,0);    if(s->known_shift == s->s->size_shift)    return low_end_shared_string(s->s);    return end_shared_string(s->s);   }      PMOD_EXPORT PCHARP MEMCHR_PCHARP(PCHARP ptr, int chr, ptrdiff_t len)   {    switch(ptr.shift)    { -  case 0: return MKPCHARP(MEMCHR0(ptr.ptr,chr,len),0); +  case 0: return MKPCHARP(MEMCHR(ptr.ptr,chr,len),0);    case 1: return MKPCHARP(MEMCHR1((p_wchar1 *)ptr.ptr,chr,len),1);    case 2: return MKPCHARP(MEMCHR2((p_wchar2 *)ptr.ptr,chr,len),2);    }   #ifdef PIKE_DEBUG    Pike_fatal("Illegal shift in MEMCHR_PCHARP.\n");   #endif    return MKPCHARP(0,0); /* make wcc happy */   }      #define DIGIT(x) (WIDE_ISDIGIT(x) ? (x) - '0' : \
pike.git/src/stralloc.c:3213:    return neg ? LONG_MIN : LONG_MAX;    }    else {    if (neg)    return (long)(~val + 1);    else    return (long) val;    }   }    - PMOD_EXPORT int string_to_svalue_inumber(struct svalue *r, + /* + static int string_to_svalue_inumber(struct svalue *r,    char * str,    char **ptr,    int base,    int maxlength)   {    PCHARP tmp;    int ret=pcharp_to_svalue_inumber(r,    MKPCHARP(str,0),    &tmp,    base,    maxlength);    if(ptr) *ptr=(char *)tmp.ptr;    return ret;   } -  + */    - PMOD_EXPORT int wide_string_to_svalue_inumber(struct svalue *r, + int wide_string_to_svalue_inumber(struct svalue *r,    void * str,    void *ptr,    int base,    ptrdiff_t maxlength,    int shift)   {    PCHARP tmp;    int ret=pcharp_to_svalue_inumber(r,    MKPCHARP(str,shift),    &tmp,