summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorultramage <ultramage@54d463be-8e91-2dee-dedb-b68131a5f0ec>2007-10-13 03:00:51 +0000
committerultramage <ultramage@54d463be-8e91-2dee-dedb-b68131a5f0ec>2007-10-13 03:00:51 +0000
commita268f0dce511b6549cb2686d4bde2aaa6641ae33 (patch)
tree101ab7d22f5dc6e68fa1a8926ae7c9ecdc71234f
parent492dee2050bbfa25a16050143cd175b8ecedf355 (diff)
downloadhercules-a268f0dce511b6549cb2686d4bde2aaa6641ae33.tar.gz
hercules-a268f0dce511b6549cb2686d4bde2aaa6641ae33.tar.bz2
hercules-a268f0dce511b6549cb2686d4bde2aaa6641ae33.tar.xz
hercules-a268f0dce511b6549cb2686d4bde2aaa6641ae33.zip
Fixed memleak hell during mapserver shutdown (if grf reading is used and the deallocation routine is actually called).
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@11439 54d463be-8e91-2dee-dedb-b68131a5f0ec
-rw-r--r--src/common/grfio.c16
-rw-r--r--src/map/map.c2
-rw-r--r--src/tool/grfio.c16
3 files changed, 24 insertions, 10 deletions
diff --git a/src/common/grfio.c b/src/common/grfio.c
index 4b68ea9fc..4e5da0a6a 100644
--- a/src/common/grfio.c
+++ b/src/common/grfio.c
@@ -777,20 +777,26 @@ static int grfio_add(char* fname)
// removes all entries
void grfio_final(void)
{
- if (filelist != NULL)
- aFree(filelist);
+ if (filelist != NULL) {
+ 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;
if (gentry_table != NULL) {
int i;
- for (i = 0; i < gentry_entrys; i++) {
+ for (i = 0; i < gentry_entrys; i++)
if (gentry_table[i] != NULL)
aFree(gentry_table[i]);
- }
+
aFree(gentry_table);
+ gentry_table = NULL;
}
- gentry_table = NULL;
gentry_entrys = gentry_maxentry = 0;
}
diff --git a/src/map/map.c b/src/map/map.c
index 3df8bee8e..553b364f5 100644
--- a/src/map/map.c
+++ b/src/map/map.c
@@ -3189,6 +3189,8 @@ void do_final(void)
}
mapindex_final();
+ if(enable_grf)
+ grfio_final();
id_db->destroy(id_db, NULL);
pc_db->destroy(pc_db, NULL);
diff --git a/src/tool/grfio.c b/src/tool/grfio.c
index b9c03cbc5..247395262 100644
--- a/src/tool/grfio.c
+++ b/src/tool/grfio.c
@@ -776,20 +776,26 @@ static int grfio_add(char* fname)
// removes all entries
void grfio_final(void)
{
- if (filelist != NULL)
- free(filelist);
+ if (filelist != NULL) {
+ 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;
if (gentry_table != NULL) {
int i;
- for (i = 0; i < gentry_entrys; i++) {
+ for (i = 0; i < gentry_entrys; i++)
if (gentry_table[i] != NULL)
free(gentry_table[i]);
- }
+
free(gentry_table);
+ gentry_table = NULL;
}
- gentry_table = NULL;
gentry_entrys = gentry_maxentry = 0;
}