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.238 2010/05/28 17:37:52 mast Exp $ + || $Id: stralloc.c,v 1.239 2010/06/15 16:10:19 grubba 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:2310:    ret = s->s->str + (s->s->len<<s->s->size_shift);    s->s->len += chars;    return ret;   }      PMOD_EXPORT void string_builder_putchar(struct string_builder *s, int ch)   {    ptrdiff_t i;    int mag = min_magnitude(ch);    -  if (mag > s->s->size_shift) { +     string_build_mkspace(s, 1, mag); -  +  if (mag > s->known_shift) {    s->known_shift = mag; -  } else if (((size_t)s->s->len) >= ((size_t)s->malloced)) { -  string_build_mkspace(s, 1, mag); -  s->known_shift = MAXIMUM(mag, s->known_shift); +     }    i = s->s->len++;    low_set_index(s->s,i,ch);    /* Ensure NUL-termination */    s->s->str[s->s->len << s->s->size_shift] = 0;   }      PMOD_EXPORT void string_builder_putchars(struct string_builder *s, int ch,    ptrdiff_t count)   {    ptrdiff_t len = s->s->len;    int mag = min_magnitude(ch);    -  if (mag > s->s->size_shift) { +     string_build_mkspace(s, count, mag); -  +  if (mag > s->known_shift) {    s->known_shift = mag; -  } else if (((size_t)s->s->len) >= ((size_t)s->malloced)) { -  string_build_mkspace(s, count, mag); -  s->known_shift = MAXIMUM(mag, s->known_shift); +     }       switch (s->s->size_shift) {    case 0:    MEMSET (STR0 (s->s) + s->s->len, ch, count);    break;    case 1: {    int i;    for (i = 0; i < count; i++)    (STR1 (s->s) + s->s->len)[i] = ch;