From: Peep P. <so...@us...> - 2004-06-14 20:58:41
|
Update of /cvsroot/agd/server/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23601 Modified Files: object.c Log Message: Removed commented code and xfree; before apply create is called, this_player is set to 0. Index: object.c =================================================================== RCS file: /cvsroot/agd/server/src/object.c,v retrieving revision 1.16 retrieving revision 1.17 diff -u -d -r1.16 -r1.17 --- object.c 12 Jun 2004 20:12:24 -0000 1.16 +++ object.c 14 Jun 2004 20:58:32 -0000 1.17 @@ -31,19 +31,9 @@ function_t *f = p; if(f->args) - xfree(f->args); + free(f->args); -#if 0 - for(i=0;i<f->code.length;i++) { - if((int) f->code.data[i] == F_PUSH_STRING) { - i++; - if(f->code.data[i]) - xfree(f->code.data[i]); - } - } -#endif - - xfree(f->code); + free(f->code); } void destruct(object_t *ob) @@ -87,15 +77,16 @@ free_var(&ob->globals[i]); } if(ob->globals) - xfree(ob->globals); - -/* free_array(&ob->globals, (void (*)(void*)) free_var); */ /* WTF? */ - + free(ob->globals); + if(ob->name) { - xfree(ob->name); + free(ob->name); } - xfree(ob); + if(this_ob == ob) + this_ob = NULL; + + free(ob); } void ref_ob(object_t *ob, variable_t *v) @@ -130,26 +121,21 @@ printf("p[%p]->ref < 0!\n", p); if(p->ref <= 0) { int i; - for(i=0;i<p->num_str;i++) - xfree(p->str_tbl[i]); - xfree(p->str_tbl); + for(i=0;i<p->num_str;i++) { + free(p->str_tbl[i]); + } + free(p->str_tbl); for(i=0;i<p->numfunc;i++) { free_fun(p->functions[i]); - xfree(p->fun_table[i]); + free(p->fun_table[i]); } if(p->numfunc) { - xfree(p->functions); - xfree(p->fun_table); + free(p->functions); + free(p->fun_table); } -/* Again: WTF? */ -/* - free_array(&p->functions, free_fun); - free_array(&p->fun_table, NULL); -*/ - - xfree(p); + free(p); *prog = NULL; } } @@ -181,6 +167,7 @@ object_t *ob, *saved_this_ob, *saved_prev_ob; + player_t *saved_tp; if(!legal_path(path)) { printf("load_object(): illegal path name \"%s\"!\n", path); @@ -205,6 +192,9 @@ unref_prog(&ob->prog); /* new_prog is already referenced by compile_prog() */ ob->prog = new_prog; + + saved_tp = this_player; + this_player = NULL; apply(ob, "create", NULL); goto out; } @@ -213,21 +203,25 @@ /* path = remove_extension(path); ? */ ob = xmalloc(sizeof(object_t)); memset(ob, 0, sizeof(object_t)); - ob->name = path; + ob->name = stringdup(path); this_ob = ob; ob->prog = compile_prog(path); if(!ob->prog) { - xfree(ob); + free(ob); ob = NULL; goto out; } list_push(&all_objects, ob); + + saved_tp = this_player; + this_player = NULL; apply(ob, "create", NULL); out: + this_player = saved_tp; this_ob = saved_this_ob; previous_ob = saved_prev_ob; return ob; |