pike.git / src / stralloc.c

version» Context lines:

pike.git/src/stralloc.c:8:   #include "pike_macros.h"   #include "dynamic_buffer.h"   #include "pike_macros.h"   #include "pike_memory.h"   #include "error.h"   #include "gc.h"   #include "stuff.h"      #include <ctype.h>    - RCSID("$Id: stralloc.c,v 1.41 1998/10/11 21:07:30 grubba Exp $"); + RCSID("$Id: stralloc.c,v 1.42 1998/10/11 22:34:02 hubbe Exp $");      #define BEGIN_HASH_SIZE 997   #define MAX_AVG_LINK_LENGTH 3   #define HASH_PREFIX 64      unsigned INT32 htable_size=0;   static unsigned int hashprimes_entry=0;   static struct pike_string **base_table=0;   static unsigned INT32 full_hash_value;   unsigned INT32 num_strings=0;
pike.git/src/stralloc.c:1064:    {    /* String must be grown */    struct pike_string *b;       switch(TWO_SIZES(min_magnitude(c),a->size_shift))    {    case TWO_SIZES(1,0):    b=begin_wide_shared_string(a->len,1);    convert_0_to_1(STR1(b),a->str,a->len);    STR1(b)[index]=c; +  free_string(a);    return end_shared_string(b);       case TWO_SIZES(2,0):    b=begin_wide_shared_string(a->len,2);    convert_0_to_2(STR2(b),a->str,a->len);    STR2(b)[index]=c; -  +  free_string(a);    return end_shared_string(b);       case TWO_SIZES(2,1):    b=begin_wide_shared_string(a->len,2);    convert_1_to_2(STR2(b),STR1(a),a->len);    STR2(b)[index]=c; -  +  free_string(a);    return end_shared_string(b);       default:    fatal("Odd wide string conversion!\n");    }    }          /* Next we test if the new string can be shrunk    * if all characters in the new string can fit in a string
pike.git/src/stralloc.c:1528:   {    string_build_mkspace(s,str->len,s->s->size_shift);       pike_string_cpy(s->s->str + (s->s->len << s->s->size_shift),    s->s->size_shift,    str);    s->known_shift=MAXIMUM(s->known_shift,str->size_shift);    s->s->len+=str->len;   }    +  + void reset_string_builder(struct string_builder *s) + { +  s->known_shift=0; +  s->s->len=0; + } +    struct pike_string *finish_string_builder(struct string_builder *s)   {    low_set_index(s->s,s->s->len,0);    if(s->known_shift == s->s->size_shift)    return low_end_shared_string(s->s);    return end_shared_string(s->s);   }