Branch: Tag:

1998-02-11

1998-02-11 00:05:03 by Fredrik Hübinette (Hubbe) <hubbe@hubbe.net>

lots of minor fixes

Rev: src/Makefile.in:1.57
Rev: src/configure.in:1.158
Rev: src/dmalloc.h:1.4
Rev: src/fd_control.c:1.13
Rev: src/fd_control.h:1.2
Rev: src/fdlib.c:1.12
Rev: src/fdlib.h:1.9
Rev: src/main.c:1.41
Rev: src/mapping.c:1.28
Rev: src/pike_memory.c:1.13
Rev: src/stralloc.c:1.27
Rev: src/time_stuff.h:1.7

13:   #include "gc.h"   #include "stuff.h"    + #include <ctype.h> +    #define BEGIN_HASH_SIZE 997   #define MAX_AVG_LINK_LENGTH 3   #define HASH_PREFIX 20
30:    return full_hash_value % htable_size;   }    + #ifdef DEBUG_MALLOC + static void locate_problem(int (*isproblem)(struct pike_string *)) + { +  unsigned INT32 e; +  struct pike_string *s; +  struct memhdr *yes=alloc_memhdr(); +  struct memhdr *no=alloc_memhdr();    -  +  for(e=0;e<htable_size;e++) +  for(s=base_table[e];s;s=s->next) +  add_marks_to_memhdr(isproblem(s)?yes:no,s); +  +  fprintf(stderr,"Plausible problem location(s):\n"); +  dump_memhdr_locations(yes,no); + } +  + static int has_zero_refs(struct pike_string *s) + { +  return s->refs<=0; + } + static int wrong_hash(struct pike_string *s) + { +  return s->hval != StrHash(s->str, s->len); + } + static int improper_zero_termination(struct pike_string *s) + { +  return s->str[s->len]; + } + #else + #define locate_problem(X) + #endif +    /*** find a string in the shared string table. ***/   static struct pike_string *internal_findstring(const char *s,int len,int h)   {
42: Inside #if defined(DEBUG)
   if(curr->refs<1)    {    debug_dump_pike_string(curr, 70); +  locate_problem(has_zero_refs);    fatal("String with no references.\n");    }   #endif
90: Inside #if defined(DEBUG)
   if(curr->refs<1)    {    debug_dump_pike_string(curr, 70); +  locate_problem(has_zero_refs);    fatal("String with no references.\n");    }   #endif
294: Inside #if defined(DEBUG)
  {    StrHash(s->str, s->len);    if(full_hash_value != s->hval) +  { +  locate_problem(wrong_hash);    fatal("Hash value changed?\n"); -  +  }       if(debug_findstring(s) !=s)    fatal("Shared string not shared.\n");       if(s->str[s->len]) -  +  { +  locate_problem(improper_zero_termination);    fatal("Shared string is not zero terminated properly.\n");    } -  + }      void verify_shared_strings_tables(void)   {
318: Inside #if defined(DEBUG)
   fatal("Shared string shorter than zero bytes.\n");       if(s->refs <= 0) +  { +  locate_problem(has_zero_refs);    fatal("Shared string had too few references.\n"); -  +  }       if(s->str[s->len]) -  +  { +  locate_problem(improper_zero_termination);    fatal("Shared string didn't end with a zero.\n"); -  +  }       if(StrHash(s->str, s->len) != e) -  +  { +  locate_problem(wrong_hash);    fatal("Shared string hashed to wrong place.\n"); -  +  }       if(s->hval != full_hash_value)    fatal("Shared string hashed to other number.\n");