Fixed memleak hell during mapserver shutdown (if grf reading is used and the deallocation routine is actually called).

git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@11439 54d463be-8e91-2dee-dedb-b68131a5f0ec
This commit is contained in:
ultramage 2007-10-13 03:00:51 +00:00
parent d2e2f9924f
commit 74c5d717aa
3 changed files with 24 additions and 10 deletions

View File

@ -777,20 +777,26 @@ static int grfio_add(char* fname)
// removes all entries // removes all entries
void grfio_final(void) void grfio_final(void)
{ {
if (filelist != NULL) if (filelist != NULL) {
aFree(filelist); int i;
for (i = 0; i < filelist_entrys; i++)
if (filelist[i].fnd != NULL)
aFree(filelist[i].fnd);
aFree(filelist);
filelist = NULL;
}
filelist_entrys = filelist_maxentry = 0; filelist_entrys = filelist_maxentry = 0;
if (gentry_table != NULL) { if (gentry_table != NULL) {
int i; int i;
for (i = 0; i < gentry_entrys; i++) { for (i = 0; i < gentry_entrys; i++)
if (gentry_table[i] != NULL) if (gentry_table[i] != NULL)
aFree(gentry_table[i]); aFree(gentry_table[i]);
}
aFree(gentry_table); aFree(gentry_table);
gentry_table = NULL;
} }
gentry_table = NULL;
gentry_entrys = gentry_maxentry = 0; gentry_entrys = gentry_maxentry = 0;
} }

View File

@ -3189,6 +3189,8 @@ void do_final(void)
} }
mapindex_final(); mapindex_final();
if(enable_grf)
grfio_final();
id_db->destroy(id_db, NULL); id_db->destroy(id_db, NULL);
pc_db->destroy(pc_db, NULL); pc_db->destroy(pc_db, NULL);

View File

@ -776,20 +776,26 @@ static int grfio_add(char* fname)
// removes all entries // removes all entries
void grfio_final(void) void grfio_final(void)
{ {
if (filelist != NULL) if (filelist != NULL) {
free(filelist); int i;
for (i = 0; i < filelist_entrys; i++)
if (filelist[i].fnd != NULL)
free(filelist[i].fnd);
free(filelist);
filelist = NULL;
}
filelist_entrys = filelist_maxentry = 0; filelist_entrys = filelist_maxentry = 0;
if (gentry_table != NULL) { if (gentry_table != NULL) {
int i; int i;
for (i = 0; i < gentry_entrys; i++) { for (i = 0; i < gentry_entrys; i++)
if (gentry_table[i] != NULL) if (gentry_table[i] != NULL)
free(gentry_table[i]); free(gentry_table[i]);
}
free(gentry_table); free(gentry_table);
gentry_table = NULL;
} }
gentry_table = NULL;
gentry_entrys = gentry_maxentry = 0; gentry_entrys = gentry_maxentry = 0;
} }