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.219 2008/05/11 14:55:54 mast Exp $ + || $Id: stralloc.c,v 1.220 2008/06/16 21:46: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:595:    really_free_short_pike_string1((struct short_pike_string1 *)s); \    DO_IF_DEBUG( \    } else if (s->size_shift != 2) { \    Pike_fatal("Unsupported string shift: %d\n", s->size_shift); \    ) \    } else { \    really_free_short_pike_string2((struct short_pike_string2 *)s); \    } \    } while(0)    - #define really_free_pike_string(s) do { \ + #define free_unlinked_pike_string(s) do { \    if (s->len <= SHORT_STRING_THRESHOLD) { \    really_free_short_pike_string(s); \    } else { \    debug_free((char *)s, DMALLOC_LOCATION(), 1); \    } \    } while(0)      /* note that begin_shared_string expects the _exact_ size of the string,    * not the maximum size    */
pike.git/src/stralloc.c:1029:    UNLOCK_BUCKET(s->hval);    s->flags |= STRING_NOT_SHARED;   }      PMOD_EXPORT void do_free_string(struct pike_string *s)   {    if (s)    free_string(s);   }    - PMOD_EXPORT void do_really_free_string(struct pike_string *s) + PMOD_EXPORT void do_free_unlinked_pike_string(struct pike_string *s)   {    if (s) -  really_free_string(s); +  free_unlinked_pike_string(s);   }    - PMOD_EXPORT void do_really_free_pike_string(struct pike_string *s) - { -  if (s) -  really_free_pike_string(s); - } -  +    PMOD_EXPORT void really_free_string(struct pike_string *s)   {   #ifdef PIKE_DEBUG    extern int d_flag;    if (s->refs) {   #ifdef DEBUG_MALLOC    describe_something(s, T_STRING, 0,2,0, NULL);   #endif    Pike_fatal("Freeing string with %d references.\n", s->refs);    }
pike.git/src/stralloc.c:1066: Inside #if defined(PIKE_DEBUG)
   if(((ptrdiff_t)s->next) & 1)    Pike_fatal("Freeing shared string again, memory corrupt or other bug!\n");    }    if ((s->size_shift < 0) || (s->size_shift > 2)) {    Pike_fatal("Freeing string with bad shift (0x%08x); could it be a type?\n",    s->size_shift);    }   #endif    if (!(s->flags & STRING_NOT_SHARED))    unlink_pike_string(s); -  really_free_pike_string(s); +  free_unlinked_pike_string(s);    GC_FREE_SIMPLE_BLOCK(s);   }    -  + PMOD_EXPORT void do_really_free_string(struct pike_string *s) + { +  if (s) +  really_free_string(s); + } +    PMOD_EXPORT void debug_free_string(struct pike_string *s)   {    if(!sub_ref(s))    really_free_string(s);   }         /*    * String table status    */
pike.git/src/stralloc.c:2067:    }   #endif       for(e=0;e<htable_size;e++)    {    LOCK_BUCKET(e);    for(s=base_table[e];s;s=next)    {    next=s->next;   #ifdef REALLY_FREE -  really_free_pike_string(s); +  free_unlinked_pike_string(s);   #else    s->next=0;   #endif    }    base_table[e]=0;    UNLOCK_BUCKET(e);    }    free((char *)base_table);    base_table=0;    num_strings=0;