Originally posted by [b]Brainstorm[/b]
http://www.eathena.ws/board/index.php?autocom=bugtracker&showbug=1509
CODE
Memory manager: Memory leaks found at 2008/05/14 05h17m53s (Revision 129M).
0001 : script.c line 2974 size 48 address 0x0x287c9464
0002 : script.c line 2974 size 48 address 0x0x287c9c64
0003 : script.c line 2974 size 48 address 0x0x287c9ce4
0004 : script.c line 2976 size 20 address 0x0x2eeb13ec
0005 : script.c line 2976 size 20 address 0x0x2eeb186c
0006 : script.c line 2976 size 20 address 0x0x2eeb19ec
0007 : script.c line 2981 size 4 address 0x0x31729344
0008 : script.c line 2981 size 4 address 0x0x31729524
0009 : script.c line 2981 size 4 address 0x0x31729664
0010 : script.c line 2979 size 768 address 0x0x323182c4
0011 : script.c line 2979 size 768 address 0x0x323188e4
0012 : script.c line 2979 size 768 address 0x0x32318bf4
CODE
void run_script_main(struct script_state *st);
void run_script(struct script_code *rootscript,int pos,int rid,int oid)
{
struct script_state *st;
TBL_PC *sd=NULL;
if(rootscript==NULL || pos<0)
return;
if (rid) sd = map_id2sd(rid);
if (sd && sd->st && sd->st->scriptroot == rootscript && sd->st->pos == pos){
//Resume script.
st = sd->st;
} else {
st = (struct script_state*)aCalloc(sizeof(struct script_state), 1);
// the script is different, make new script_state and stack
st->stack = (struct script_stack*)aMalloc (sizeof(struct script_stack));
st->stack->sp=0;
st->stack->sp_max=64;
st->stack->stack_data = (struct script_data *)aCalloc(st->stack->sp_max,sizeof(st->stack->stack_data[0]));
st->stack->defsp = st->stack->sp;
st->stack->var_function = (struct linkdb_node**)aCalloc(1, sizeof(struct linkdb_node*));
st->state = RUN;
st->script = rootscript;
}
st->pos = pos;
st->rid = rid;
st->oid = oid;
st->sleep.timer = INVALID_TIMER;
run_script_main(st);
}