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.233 2008/11/05 15:03:39 grubba Exp $ + || $Id: stralloc.c,v 1.234 2009/01/06 10:04:24 srb 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:2226:    h++;    LOCK_BUCKET(h);    h = HMODULO(h);    next = base_table[h];    UNLOCK_BUCKET(h);    } while (!next);    }    return next;   }    - PMOD_EXPORT void init_string_builder(struct string_builder *s, int mag) + PMOD_EXPORT void init_string_builder_alloc(struct string_builder *s, ptrdiff_t length, int mag)   { -  s->malloced=256; -  s->s=begin_wide_shared_string(256,mag); +  s->s=begin_wide_shared_string(length,mag); +  s->malloced=length; +  s->known_shift=0;    s->s->len=0;    low_set_index (s->s, 0, 0); -  s->known_shift=0; +    }    - PMOD_EXPORT void init_string_builder_alloc(struct string_builder *s, ptrdiff_t length, int mag) + PMOD_EXPORT void init_string_builder(struct string_builder *s, int mag)   { -  s->malloced=length; -  s->s=begin_wide_shared_string(length,mag); -  s->s->len=0; -  low_set_index (s->s, 0, 0); -  s->known_shift=0; +  init_string_builder_alloc(s, 256, mag);   }      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;