--- Dale Kingston <[EMAIL PROTECTED]> wrote:
> Heres my constructor:
> quest_data ::quest_data()
> {
> memset(this, 0, sizeof(*this));
> this->qArea_list = NULL;
> this->current_quests = NULL;
> this->quest_item_table = NULL;
> return;
> }
It is generally not wise to use memset with classes specifically classes which
use virtual methods ( which I would recommend if you are really going for an OO
design ). Memset will overwrite the vtable pointer in the classes internals,
and will cause virtual methods to segfault. If you want this sort of
initialization have the constructor set each private variable to 0 or whatever,
but don't use memset.
> and Heres my deconstrcutor
> quest_data ::~quest_data()
> {
> QUEST_TABLE_DATA *quest;
> struct quest_area_type *list, *next_in_list;
>
> free(this->quest_item_table);
>
> for (quest = this->current_quests; quest != NULL; quest = quest->next)
> this->remove_quest(quest);
>
> for (list = this->qArea_list; list != NULL; list = next_in_list)
> {
> next_in_list = list->next;
> free(list);
> }
>
> return;
> }
Two words.. STL List. Also, you shouldn't be using malloc/free so much as you
should be using new/delete.
Just some thoughts
=====
-----BEGIN GEEK CODE BLOCK-----
Version 3.1
GCS/L/C/O d-(+) s++: a-- C+++$>++++ UBLS++++$
P+++(--)$ L+++>++++ E--- W+>++$ N !o K? w(--) !O
M- !V PS+ PE(++) Y+ PGP->+ t+ 5 X+() R(+) tv+@
b++(+++) !DI+++ D G(-) e>+++$ h---() r+++ y+++
------END GEEK CODE BLOCK------
__________________________________________________
Do you Yahoo!?
HotJobs - Search new jobs daily now
http://hotjobs.yahoo.com/