1998-01-26
1998-01-26 20:01:58 by Fredrik Hübinette (Hubbe) <hubbe@hubbe.net>
-
3c0c282ac55f12128086d8ff4e92ee1d6187fdb8
(79 lines)
(+76/-3)
[
Show
| Annotate
]
Branch: 7.9
many minor memory leaks fixed
Rev: NT/.cvsignore:1.3
Rev: src/array.c:1.23
Rev: src/dmalloc.h:1.2
Rev: src/dynamic_buffer.c:1.7
Rev: src/dynamic_buffer.h:1.5
Rev: src/dynamic_load.c:1.23
Rev: src/error.h:1.10
Rev: src/interpret.c:1.62
Rev: src/interpret.h:1.17
Rev: src/language.yacc:1.55
Rev: src/las.c:1.45
Rev: src/las.h:1.12
Rev: src/lex.c:1.41
Rev: src/main.c:1.37
Rev: src/main.h:1.5
Rev: src/modules/Gmp/mpz_glue.c:1.25
Rev: src/modules/Image/font.c:1.27
Rev: src/object.c:1.34
Rev: src/object.h:1.14
Rev: src/operators.c:1.23
Rev: src/pike_memory.c:1.5
Rev: src/pike_types.c:1.30
Rev: src/pike_types.h:1.8
Rev: src/program.c:1.55
Rev: src/program.h:1.28
Rev: src/stralloc.c:1.25
Rev: src/stralloc.h:1.13
Rev: src/svalue.h:1.10
Rev: src/threads.c:1.54
4:
||| See the files COPYING and DISCLAIMER for more information.
\*/
#include "global.h"
- RCSID("$Id: las.c,v 1.44 1998/01/26 02:34:50 grubba Exp $");
+ RCSID("$Id: las.c,v 1.45 1998/01/26 19:59:54 hubbe Exp $");
#include "language.h"
#include "interpret.h"
73:
}
}
+ #ifdef DEBUG
+ void check_tree(node *n, int depth)
+ {
+ if(!d_flag) return;
+ if(!n) return;
+ if(n->token==USHRT_MAX)
+ fatal("Free node in tree.\n");
+
+ if(!(depth & 1023))
+ {
+ node *q;
+ for(q=n->parent;q;q=q->parent)
+ if(q->parent==n)
+ fatal("Cyclic node structure found.\n");
+ }
+ depth++;
+
+ if(car_is_node(n))
+ {
+ if(CAR(n)->parent != n)
+ fatal("Parent is wrong.\n");
+
+ check_tree(CAR(n),depth);
+ }
+
+ if(cdr_is_node(n))
+ {
+ if(CDR(n)->parent != n)
+ fatal("Parent is wrong.\n");
+
+ check_tree(CDR(n),depth);
+ }
+ }
+ #endif
+
INT32 count_args(node *n)
{
int a,b;
-
+ check_tree(n,0);
if(!n) return 0;
switch(n->token)
{
129:
{
struct pike_string *a,*b;
+ check_tree(n,0);
+
if(!n) return 0;
if(!(n->tree_info & OPT_RETURN)) return 0;
if(car_is_node(n))
169:
struct node_chunk *tmp2;
int e=0;
-
+ #ifndef DEBUG
if(cumulative_parse_error)
{
-
+ #endif
for(tmp2=node_chunks;tmp2;tmp2=tmp2->next) e+=NODES;
for(tmp=free_nodes;tmp;tmp=CAR(tmp)) e--;
192: Inside #if defined(DEBUG)
#ifdef DEBUG
if(!cumulative_parse_error)
{
- fprintf(stderr,"Free node at %p.\n",tmp);
+ fprintf(stderr,"Free node at %p, (%s:%d) (token=%d).\n",tmp, tmp->current_file->str, tmp->line_number, tmp->token);
+ if(tmp->token==F_CONSTANT)
+ print_tree(tmp);
}
else
#endif
201:
/* Make sure we don't free any nodes twice */
if(car_is_node(tmp)) CAR(tmp)=0;
if(cdr_is_node(tmp)) CDR(tmp)=0;
+ debug_malloc_touch(tmp->type);
free_node(tmp);
}
}
211:
fatal("Failed to free %d nodes when compiling!\n",e2);
#endif
}
+ #ifndef DEBUG
}
-
+ #endif
while(node_chunks)
{
tmp2=node_chunks;
242:
}
n->token=USHRT_MAX;
if(n->type) free_string(n->type);
+ #ifdef DEBUG
+ if(n->current_file) free_string(n->current_file);
+ #endif
CAR(n)=free_nodes;
free_nodes=n;
}
267:
free_nodes=CAR(res);
res->token=0;
res->line_number=lex.current_line;
+ #ifdef DEBUG
+ copy_shared_string(res->current_file, lex.current_file);
+ #endif
res->type=0;
res->node_info=0;
res->tree_info=0;
277:
node *mknode(short token,node *a,node *b)
{
node *res;
+ check_tree(a,0);
+ check_tree(b,0);
res = mkemptynode();
CAR(res) = a;
CDR(res) = b;
342:
if(b) b->parent = res;
if(!num_parse_error && compiler_pass==2)
+ {
+ check_tree(res,0);
optimize(res);
-
+ check_tree(res,0);
+ }
#ifdef DEBUG
if(d_flag > 3)
454:
CDR(res)=0;
#endif
res->u.number = i;
+ check_tree(res,0);
return res;
}
505:
struct program *p;
INT32 numid;
+ check_tree(n,0);
+
if(!n)
{
push_int(0);
562:
void resolv_program(node *n)
{
+ check_tree(n,0);
+
resolv_constant(n);
switch(sp[-1].type)
{
595:
{
node *ret;
JMP_BUF tmp;
+
+ check_tree(n,0);
+
if(SETJMP(tmp))
{
ONERROR tmp;
644:
int node_is_eq(node *a,node *b)
{
+ check_tree(a,0);
+ check_tree(b,0);
+
if(a == b) return 1;
if(!a || !b) return 0;
if(a->token != b->token) return 0;
737:
node *copy_node(node *n)
{
node *b;
+ check_tree(n,0);
if(!n) return n;
switch(n->token)
{
989:
void print_tree(node *n)
{
+ check_tree(n,0);
low_print_tree(n,0);
printf("\n");
fflush(stdout);
1540:
}
}
fix_type_field(n);
+ debug_malloc_touch(n->type);
#ifdef DEBUG
if(l_flag > 3 && n)
2153:
int args, vargs, ret;
struct svalue *foo;
+ check_tree(n,0);
+
#ifdef DEBUG
if(a_flag > 1)
fprintf(stderr,"Doing function '%s' at %x\n",name->str,PC);