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.202 2005/11/05 15:28:00 grubba Exp $ + || $Id: stralloc.c,v 1.203 2006/01/12 10:52:16 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:615:    if (len <= SHORT_STRING_THRESHOLD) {    t=(struct pike_string *)alloc_short_pike_string0();    } else {    t=(struct pike_string *)xalloc(len + sizeof(struct pike_string));    t->flags = STRING_NOT_HASHED | STRING_NOT_SHARED;    }    t->refs = 1;    t->str[len]=0;    t->len=len;    t->size_shift=0; +  DO_IF_DEBUG(t->next = NULL);    return t;   }      static void link_pike_string(struct pike_string *s, size_t hval)   {    size_t h;      #ifdef PIKE_DEBUG    if (!(s->flags & STRING_NOT_SHARED)) {    debug_dump_pike_string(s, 70);
pike.git/src/stralloc.c:729:    } else {    t = (struct pike_string *)alloc_short_pike_string2();    }    } else {    t=(struct pike_string *)xalloc((len<<shift) + sizeof(struct pike_string));    t->flags = STRING_NOT_HASHED|STRING_NOT_SHARED;    }    t->refs = 1;    t->len=len;    t->size_shift=shift; +  DO_IF_DEBUG(t->next = NULL);    low_set_index(t,len,0);    return t;   }      PMOD_EXPORT void hash_string(struct pike_string *s)   {    if (!(s->flags & STRING_NOT_HASHED)) return;    s->hval=do_hash(s);    s->flags &= ~STRING_NOT_HASHED;   }
pike.git/src/stralloc.c:822:    s=s2;    }    break;       case 0: break;    }       return low_end_shared_string(s);   }    + PMOD_EXPORT struct pike_string *defer_end_string(struct pike_string *s) + { + #ifdef STRING_DEFER_THRESHOLD +  if (s->len > STRING_DEFER_THRESHOLD) { +  return s; +  } + #endif +  return end_shared_string(s); + } +    PMOD_EXPORT struct pike_string *end_and_resize_shared_string(struct pike_string *str, ptrdiff_t len)   {    struct pike_string *tmp;   #ifdef PIKE_DEBUG    if(len > str->len)    Pike_fatal("Cannot extend string here!\n");   #endif    if( str->len <= SHORT_STRING_THRESHOLD ?    (len <= SHORT_STRING_THRESHOLD) :    (len > SHORT_STRING_THRESHOLD) && str->len > len/2 )