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.171 2006/03/14 17:39:03 grubba Exp $ + || $Id: stralloc.c,v 1.172 2008/06/23 18:56:34 mast 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:17:   #include "bignum.h"   #include "interpret.h"   #include "block_alloc.h"   #include "operators.h"      #include <errno.h>   #include <float.h>   #include <ctype.h>   #include <math.h>    - RCSID("$Id: stralloc.c,v 1.171 2006/03/14 17:39:03 grubba Exp $"); + RCSID("$Id: stralloc.c,v 1.172 2008/06/23 18:56:34 mast Exp $");      /* #define STRALLOC_USE_PRIMES */      #ifdef STRALLOC_USE_PRIMES      #define SET_HSIZE(X) htable_size=hashprimes[(X)]   #define HMODULO(X) ((X) % htable_size)      #else   
pike.git/src/stralloc.c:1980:    } while (!next);    }    return next;   }      PMOD_EXPORT void init_string_builder(struct string_builder *s, int mag)   {    s->malloced=256;    s->s=begin_wide_shared_string(256,mag);    s->s->len=0; -  s->s->str[0] = 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)   {    s->malloced=length;    s->s=begin_wide_shared_string(length,mag);    s->s->len=0; -  s->s->str[0] = 0; +  low_set_index (s->s, 0, 0);    s->known_shift=0;   }      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->s->len, from->s->size_shift); -  MEMCPY (to->s->str, from->s->str, from->s->len << from->s->size_shift); +  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. */
pike.git/src/stralloc.c:2202:    /* Ensure NUL-termination */    s->s->str[s->s->len << s->s->size_shift] = 0;   }         PMOD_EXPORT void reset_string_builder(struct string_builder *s)   {    s->known_shift=0;    s->s->len=0;    /* Ensure NUL-termination */ -  s->s->str[0] = 0; +  low_set_index (s->s, 0, 0);   }      PMOD_EXPORT void free_string_builder(struct string_builder *s)   {    s->s->len = s->malloced;    really_free_pike_string(s->s);   }      PMOD_EXPORT struct pike_string *finish_string_builder(struct string_builder *s)   {