From: <bal...@us...> - 2003-12-25 23:50:09
|
Update of /cvsroot/gemrb/gemrb/gemrb/plugins/Core In directory sc8-pr-cvs1:/tmp/cvs-serv18723/gemrb/plugins/Core Modified Files: Dialog.h Dialog.cpp Log Message: Added Feature : Dialog.cpp / .h : Added freeing functions (the Dialog class should be complete) Index: Dialog.h =================================================================== RCS file: /cvsroot/gemrb/gemrb/gemrb/plugins/Core/Dialog.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Dialog.h 23 Dec 2003 23:43:50 -0000 1.2 --- Dialog.h 25 Dec 2003 23:50:04 -0000 1.3 *************** *** 70,73 **** --- 70,76 ---- DialogState* GetState(int index); char ResRef[9]; + private: + void FreeDialogState(DialogState *ds); + void FreeDialogString(DialogString *ds); }; Index: Dialog.cpp =================================================================== RCS file: /cvsroot/gemrb/gemrb/gemrb/plugins/Core/Dialog.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Dialog.cpp 23 Dec 2003 23:43:50 -0000 1.2 --- Dialog.cpp 25 Dec 2003 23:50:04 -0000 1.3 *************** *** 31,35 **** for(int i = 0; i < initialStates.size(); i++) { if(initialStates[i]) ! delete(initialStates[i]); } } --- 31,35 ---- for(int i = 0; i < initialStates.size(); i++) { if(initialStates[i]) ! FreeDialogState(initialStates[i]); } } *************** *** 45,47 **** --- 45,71 ---- return NULL; return initialStates.at(index); + } + + void Dialog::FreeDialogState(DialogState *ds) + { + for(int i = 0; i < ds->transitionsCount; i++) { + if(ds->transitions[i]->action) + FreeDialogString(ds->transitions[i]->action); + if(ds->transitions[i]->trigger) + FreeDialogString(ds->transitions[i]->trigger); + delete(ds->transitions[i]); + } + delete(ds->transitions); + FreeDialogString(ds->trigger); + delete(ds); + } + + void Dialog::FreeDialogString(DialogString *ds) + { + for(int i = 0; i < ds->count; i++) { + if(ds->strings[i]) + free(ds->strings[i]); + } + free(ds->strings); + delete(ds); } |