1998-03-01
1998-03-01 11:40:47 by Fredrik Hübinette (Hubbe) <hubbe@hubbe.net>
-
9e5238fba5b70ee210ab32f1f42baf4bfed2811b
(39 lines)
(+32/-7)
[
Show
| Annotate
]
Branch: 7.9
better type checking implemented (and a bug in the type checking fixed)
Rev: src/builtin_functions.c:1.76
Rev: src/docode.c:1.33
Rev: src/las.c:1.55
Rev: src/operators.c:1.28
Rev: src/pike_types.c:1.34
Rev: src/program.c:1.65
Rev: src/stralloc.c:1.28
Rev: src/svalue.h:1.13
32:
return full_hash_value % htable_size;
}
+ #ifdef DEBUG
#ifdef DEBUG_MALLOC
-
+ #define DM(X) X
+ #else
+ #define DM(X)
+ #endif
+
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();
+ DM(struct memhdr *yes=alloc_memhdr());
+ DM(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);
+ {
+ if(isproblem(s))
+ {
+ fprintf(stderr,"***Guilty string:\n");
+ debug_dump_pike_string(s, 70);
+ DM(add_marks_to_memhdr(yes,s));
+ }else{
+ DM(add_marks_to_memhdr(no,s));
+ }
+ }
+ }
- fprintf(stderr,"Plausible problem location(s):\n");
- dump_memhdr_locations(yes,no);
+ DM(fprintf(stderr,"Plausible problem location(s):\n"));
+ DM(dump_memhdr_locations(yes,0));
+
+ DM(fprintf(stderr,"More Plausible problem location(s):\n"));
+ DM(dump_memhdr_locations(yes,no));
}
static int has_zero_refs(struct pike_string *s)
54: Inside #if defined(DEBUG_MALLOC)
}
static int wrong_hash(struct pike_string *s)
{
- return s->hval != StrHash(s->str, s->len);
+ return (s->hval % htable_size) != StrHash(s->str, s->len);
}
static int improper_zero_termination(struct pike_string *s)
{
196:
len=s->len;
h=StrHash(s->str,len);
s2=internal_findstring(s->str,len,h);
+ #ifdef DEBUG
+ if(s2==s)
+ fatal("end_shared_string called twice! (or something like that)\n");
+ #endif
if(s2)
{
450: Inside #if defined(DEBUG)
void debug_dump_pike_string(struct pike_string *s, INT32 max)
{
INT32 e;
- fprintf(stderr,"0x%p: %ld refs, len=%ld, hval=%lux (%lux)\n",
+ fprintf(stderr,"0x%p: %ld refs, len=%ld, hval=%lux (%lx)\n",
s,
(long)s->refs,
(long)s->len,