valgrind -v –tool=memcheck –leak-check=full –show-reachable=yes –demangle=yes –db-attach=yes –num-callers=10 –track-origins=yes –track-fds=yes ./<engine>
void clear_memory() {
int i;
//clear socials
for (i=0; i< MAX_SOCIALS; i++) {
free_string(&social_table[i].char_no_arg);
free_string(&social_table[i].others_no_arg);
free_string(&social_table[i].char_found);
free_string(&social_table[i].others_found);
free_string(&social_table[i].vict_found);
free_string(&social_table[i].char_not_found);
free_string(&social_table[i].char_auto);
free_string(&social_table[i].others_auto);
}
//clear clans
CLAN_DATA *clan, *clan_next;
for (clan = clan_list;clan ;clan = clan_next) {
clan_next = clan->next;
free_clan(clan);
}
//clear legend and pk board
for (i = 0;i < LEGEND_BOARD_SIZE;i ++)
free_string( &pLeg[i].name);
for (i = 0;i < PK_BOARD_SIZE;i ++) {
free_string( &pPK[i].name);
free_string( &pPK[i].rank_name);
}
//let see if we did our job correctly till yet
//clear the char/mobs loaded
CHAR_DATA *ch, *ch_next;
for (ch = char_list;ch ;ch = ch_next) {
ch_next = ch->next;
extract_char(ch, TRUE, CHAR_RETURN_LIST);
free_char(ch);
}
char_list = NULL;
//clear the loaded objects
OBJ_DATA *obj, *obj_next;
for (obj = object_list;obj ;obj = obj_next) {
obj_next = obj->next;
extract_obj(obj);
free_obj(obj);
}
object_list = NULL;
//clear the object index
int iHash;
OBJ_INDEX_DATA *pObjIndex, *pObjIndex_next;
for (iHash = 0;iHash < MAX_KEY_HASH;iHash ++)
for (pObjIndex = obj_index_hash[iHash];pObjIndex ;pObjIndex = pObjIndex_next) {
pObjIndex_next = pObjIndex->next;
free_obj_index(pObjIndex);
}
DISABLED_DATA *disabledD, *disabledD_next;
for (disabledD = disabled_first;disabledD;disabledD = disabledD_next) {
disabledD_next = disabledD->next;
free_string( &disabledD->disabled_by);
free(disabledD);
}
disabled_first = NULL;
DIS_SPELL_DATA *disabledSpellD, *disabledSpellD_next;
for (disabledSpellD = dis_spell_first;disabledSpellD;disabledSpellD = disabledSpellD_next) {
disabledSpellD_next = disabledSpellD->next;
free_string( &disabledSpellD->disabled_by);
free(disabledSpellD);
}
dis_spell_first = NULL;
HELP_DATA *help, *help_next;
for (help = help_first;help;help = help_next) {
help_next = help->next;
free_help(help);
}
help_first = NULL;
help_last = NULL;
//clear the mob_index
MOB_INDEX_DATA *pMobIndex, *pMobIndex_next;
for (iHash = 0;iHash < MAX_KEY_HASH;iHash ++)
for (pMobIndex = mob_index_hash[iHash];pMobIndex ;pMobIndex = pMobIndex_next) {
pMobIndex_next = pMobIndex->next;
free_mob_index(pMobIndex);
}
//clears shop (should be none left as when you extract a char it extracts the shop as well
SHOP_DATA *shop, *shop_next;
for (shop = shop_last;shop;shop = shop_next) {
shop_next = shop->next;
log_param("Extracting shop from %d", shop->keeper);
extract_shop(shop);
}
shop_first = NULL;
shop_last = NULL;
//clear the room_index
int vnum = 0;
AREA_DATA *pArea, *pArea_next;
for (pArea = area_first;pArea ;pArea = pArea_next) {
pArea_next = pArea->next;
log_param("Unloading area:%s", pArea->name);
for (vnum = pArea->lvnum;vnum <= pArea->uvnum;vnum ++)
extract_room_index(get_room_index(vnum));
free_area(pArea);
}
free(top_string);
free(log_file);
exit(0);
}
ch->name = strdup("name");
ch->name = strdup("othername");