Branch: Tag:

1998-01-25

1998-01-25 08:28:45 by Fredrik Hübinette (Hubbe) <hubbe@hubbe.net>

jumbopatch! (DEBUG_MALLOC + parent feature fix)

Rev: src/ChangeLog:1.130
Rev: src/acconfig.h:1.15
Rev: src/array.c:1.22
Rev: src/array.h:1.6
Rev: src/builtin_functions.c:1.62
Rev: src/builtin_functions.h:1.6
Rev: src/cpp.c:1.14
Rev: src/dmalloc.h:1.1
Rev: src/docode.c:1.25
Rev: src/dynamic_buffer.c:1.6
Rev: src/dynamic_buffer.h:1.4
Rev: src/error.c:1.10
Rev: src/error.h:1.9
Rev: src/fdlib.c:1.9
Rev: src/gc.c:1.27
Rev: src/global.h:1.13
Rev: src/interpret.c:1.61
Rev: src/language.yacc:1.54
Rev: src/las.c:1.43
Rev: src/las.h:1.11
Rev: src/lex.c:1.40
Rev: src/lex.h:1.9
Rev: src/main.c:1.35
Rev: src/main.h:1.4
Rev: src/mapping.c:1.27
Rev: src/mapping.h:1.7
Rev: src/module.c:1.7
Rev: src/modules/Image/colortable.c:1.36
Rev: src/modules/Image/encodings/gif.c:1.30
Rev: src/modules/Image/encodings/png.c:1.2
Rev: src/modules/Image/encodings/pnm.c:1.12
Rev: src/modules/Image/encodings/x.c:1.5
Rev: src/modules/Yp/yp.c:1.10
Rev: src/modules/files/efuns.c:1.44
Rev: src/modules/files/file.c:1.69
Rev: src/modules/files/socket.c:1.25
Rev: src/modules/files/socktest.pike:1.7
Rev: src/modules/spider/accesseddb.c:1.13
Rev: src/modules/spider/dumudp.c:1.32
Rev: src/modules/spider/spider.c:1.51
Rev: src/modules/system/system.c:1.39
Rev: src/multiset.c:1.9
Rev: src/object.c:1.33
Rev: src/peep.c:1.17
Rev: src/pike_memory.c:1.4
Rev: src/pike_memory.h:1.2
Rev: src/pike_types.c:1.29
Rev: src/pike_types.h:1.7
Rev: src/program.c:1.54
Rev: src/program.h:1.27
Rev: src/stralloc.c:1.24
Rev: src/stralloc.h:1.12
Rev: src/testsuite.in:1.68
Rev: src/threads.c:1.53

127:   /* note that begin_shared_string expects the _exact_ size of the string,    * not the maximum size    */ - struct pike_string *begin_shared_string(int len) + struct pike_string *debug_begin_shared_string(int len)   {    struct pike_string *t;    t=(struct pike_string *)xalloc(len + sizeof(struct pike_string));
168:    return s;   }    - struct pike_string * make_shared_binary_string(const char *str,int len) + struct pike_string * debug_make_shared_binary_string(const char *str,int len)   {    struct pike_string *s;    int h=StrHash(str,len);
186:    return s;   }    - struct pike_string *make_shared_string(const char *str) + struct pike_string *debug_make_shared_string(const char *str)   {    return make_shared_binary_string(str, strlen(str));   }
221:    free((char *)s);   }    + void debug_free_string(struct pike_string *s) + { +  if(--s->refs<=0) +  really_free_string(s); + }    -  +    /*    * String table status    */
642:    MEMSET((char *)base_table,0,sizeof(struct pike_string *)*htable_size);   }    + #ifdef DEBUG_MALLOC + struct shared_string_location *all_shared_string_locations; + #endif +  +    void cleanup_shared_string_table(void)   {    unsigned INT32 e;    struct pike_string *s,*next; -  +  + #if defined(DEBUG) && defined(DEBUG_MALLOC) +  while(all_shared_string_locations) +  { +  struct shared_string_location *x=all_shared_string_locations; +  all_shared_string_locations=x->next; +  free_string(x->s); +  x->s=0; +  } +  +  if(verbose_debug_exit) +  { +  fprintf(stderr,"Leaked strings \n"); +  dump_stralloc_strings(); +  } + #endif    for(e=0;e<htable_size;e++)    {    for(s=base_table[e];s;s=next)
660:    base_table[e]=0;    }    free((char *)base_table); +  base_table=0; +  num_strings=0;   }      void count_memory_in_strings(INT32 *num, INT32 *size)   {    unsigned INT32 e, num_=0, size_=0; -  if(!base_table) return; +  if(!base_table) +  { +  *num=*size=0; +  return; +  }    size_+=htable_size * sizeof(struct pike_string *);    for(e=0;e<htable_size;e++)    {