pike.git / src / stralloc.c

version» Context lines:

pike.git/src/stralloc.c:2329:   PMOD_EXPORT void init_string_builder_copy(struct string_builder *to,    struct string_builder *from)   {    to->malloced = from->malloced;    to->s = begin_wide_shared_string (from->malloced, from->s->size_shift);    to->s->len = from->s->len;    memcpy (to->s->str, from->s->str, (from->s->len + 1) << from->s->size_shift);    to->known_shift = from->known_shift;   }    - /* str becomes invalid if successful (i.e. nonzero returned), -  * otherwise nothing happens. */ - PMOD_EXPORT int init_string_builder_with_string (struct string_builder *s, -  struct pike_string *str) - { -  if (str->refs == 1 && str->len > SHORT_STRING_THRESHOLD) { -  /* Unlink the string and use it as buffer directly. */ -  unlink_pike_string (str); -  str->flags = STRING_NOT_SHARED; -  s->s = str; -  s->malloced = str->len; -  s->known_shift = str->size_shift; -  return 1; -  } -  return 0; - } -  +    PMOD_EXPORT void string_build_mkspace(struct string_builder *s,    ptrdiff_t chars, int mag)   /* Doesn't touch or sanity check s->known_shift. */   {    if(mag > s->s->size_shift)    {    struct pike_string *n;    ptrdiff_t l = s->s->len + chars + s->malloced;    n=begin_wide_shared_string(l,mag);    pike_string_cpy(MKPCHARP_STR(n),s->s);