pike.git / src / stralloc.c

version» Context lines:

pike.git/src/stralloc.c:241:    if((unsigned INT32)*s++>=65536)    return 2;    }while(s<e);    return 1;    }    s++;    }    return 0;   }    - static INLINE int min_magnitude(p_wchar2 c) + static INLINE int min_magnitude(const p_wchar2 c)   {    if(c<0) return 2;    if(c<256) return 0;    if(c<65536) return 1;    return 2;   }      void low_set_index(struct pike_string *s, ptrdiff_t pos, int value)   {   #ifdef PIKE_DEBUG
pike.git/src/stralloc.c:314:   CONVERT(0,1)   CONVERT(0,2)   CONVERT(1,0)   CONVERT(1,2)   CONVERT(2,0)   CONVERT(2,1)      #define TWO_SIZES(X,Y) (((X)<<2)+(Y))      void generic_memcpy(PCHARP to, -  PCHARP from, +  const 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:357:    break;    case TWO_SIZES(2,1):    convert_2_to_1((p_wchar1 *)to.ptr,(p_wchar2 *)from.ptr,len);    break;    case TWO_SIZES(2,2):    convert_2_to_2((p_wchar2 *)to.ptr,(p_wchar2 *)from.ptr,len);    break;    }   }    - PMOD_EXPORT void pike_string_cpy(PCHARP to, struct pike_string *from) + PMOD_EXPORT void pike_string_cpy(PCHARP to, const struct pike_string *from)   {    generic_memcpy(to,MKPCHARP_STR(from),from->len);   }         #ifdef PIKE_DEBUG   #ifdef DEBUG_MALLOC   #define DM(X) X   #else   #define DM(X)   #endif    - PMOD_EXPORT p_wchar2 index_shared_string(struct pike_string *s, + PMOD_EXPORT p_wchar2 index_shared_string(const struct pike_string *s,    ptrdiff_t pos)   {    if(pos > s->len || pos<0) {    if (s->len) {    Pike_fatal("String index %"PRINTPTRDIFFT"d is out of "    "range 0..%"PRINTPTRDIFFT"d.\n",    pos, s->len-1);    } else {    Pike_fatal("Attempt to index the empty string with %"PRINTPTRDIFFT"d.\n",    pos);
pike.git/src/stralloc.c:429:    UNLOCK_BUCKET(e);    }       DM(fprintf(stderr,"Plausible problem location(s):\n"));    DM(dump_memhdr_locations(yes,0,0));       DM(fprintf(stderr,"More Plausible problem location(s):\n"));    DM(dump_memhdr_locations(yes,no,0));   }    - static int bad_pointer(struct pike_string *s) + static int bad_pointer(const struct pike_string *s)   {    return (((ptrdiff_t)s)&(sizeof(struct pike_string *)-1));   }    - static int has_zero_refs(struct pike_string *s) + static int has_zero_refs(const struct pike_string *s)   {    return s->refs<=0;   } - static int wrong_hash(struct pike_string *s) + static int wrong_hash(const struct pike_string *s)   {    return s->hval != do_hash(s);   } - static int improper_zero_termination(struct pike_string *s) + static int improper_zero_termination(const struct pike_string *s)   {    return index_shared_string(s,s->len);   }   #else   #define locate_problem(X)   #endif /* PIKE_DEBUG */      /* Find a string in the shared string table.    * This assumes that the string is minimized!!!!    */
pike.git/src/stralloc.c:928:    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:1537: Inside #if defined(PIKE_DEBUG)
   UNLOCK_BUCKET(e);    }   }      #endif /* PIKE_DEBUG */         /*** String compare functions ***/      /* does not take locale into account */ - int low_quick_binary_strcmp(char *a, ptrdiff_t alen, -  char *b, ptrdiff_t blen) + int low_quick_binary_strcmp(const char *a, ptrdiff_t alen, +  const char *b, ptrdiff_t blen)   {    int tmp;    if(alen > blen)    {    tmp=MEMCMP(a, b, blen);    if(tmp) return tmp;    return 1;    }else if(alen < blen){    tmp=MEMCMP(a, b, alen);    if(tmp) return tmp;