pike.git / src / stralloc.c

version» Context lines:

pike.git/src/stralloc.c:614:      /* Without the str at the end, to get the size of the header. */   struct pike_string_hdr {    PIKE_STRING_CONTENTS;   };      /* Allocate some fixed string sizes with BLOCK_ALLOC. */      #define SHORT_STRING_BLOCK 256    - #define SHORT_STRING_THRESHOLD 15 +     -  + /* breakpoint at 50% overhead. This doubles the size of short strings +  on 64-bit systems, but it only increases memory usage for short +  strings, on average, by 25% or so. */ +  + #define SHORT_STRING_THRESHOLD ((ptrdiff_t)sizeof(struct pike_string_hdr)-1) +    struct short_pike_string0 {    PIKE_STRING_CONTENTS; -  p_wchar0 str[SHORT_STRING_THRESHOLD+1]; +  p_wchar0 str[sizeof(struct pike_string_hdr)];   };      static struct block_allocator string_allocator = BA_INIT(sizeof(struct short_pike_string0), SHORT_STRING_BLOCK);      #define free_unlinked_pike_string(s) do { \    if (s->flags & STRING_IS_SHORT) { \    ba_free(&string_allocator, s); \    } else { \    debug_free(s, DMALLOC_LOCATION(), 1); \    } \
pike.git/src/stralloc.c:651:   #endif    if (len <= SHORT_STRING_THRESHOLD)    {    t=ba_alloc(&string_allocator);    t->flags = STRING_NOT_HASHED | STRING_NOT_SHARED | STRING_IS_SHORT;    } else    {    t=xalloc(len + 1 + sizeof(struct pike_string_hdr));    t->flags = STRING_NOT_HASHED | STRING_NOT_SHARED;    } - #ifdef ATOMIC_SVALUE -  t->ref_type = T_STRING; - #endif +     t->refs = 0;    add_ref(t); /* For DMALLOC */    t->str[len]=0;    t->len=len;   /* t->min = t->max = 0; */    t->size_shift=0;    DO_IF_DEBUG(t->next = NULL);    return t;   }   
pike.git/src/stralloc.c:766: Inside #if defined(PIKE_DEBUG)
  #ifdef PIKE_DEBUG    if (shift > 2)    Pike_fatal("Unsupported string shift: %d\n", shift);   #endif /* PIKE_DEBUG */    t=ba_alloc(&string_allocator);    t->flags = STRING_NOT_HASHED|STRING_NOT_SHARED|STRING_IS_SHORT;    } else {    t=xalloc(((len + 1)<<shift) + sizeof(struct pike_string_hdr));    t->flags = STRING_NOT_HASHED|STRING_NOT_SHARED;    } - #ifdef ATOMIC_SVALUE -  t->ref_type = T_STRING; - #endif +     t->refs = 0;    add_ref(t); /* For DMALLOC */    t->len=len;    t->size_shift=shift;    DO_IF_DEBUG(t->next = NULL);    low_set_index(t,len,0);    return t;   }      /*