diff options
author | celest <celest@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2005-03-23 15:26:52 +0000 |
---|---|---|
committer | celest <celest@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2005-03-23 15:26:52 +0000 |
commit | 33b8fd47955eeab26cede233b14d683b8e0491b8 (patch) | |
tree | 041f7df2acc8b46bdb56512f06b0f9706fe6ec29 /src/char_sql | |
parent | 7d3fedfa5c264169c544fe3ec977229c50e4baa2 (diff) | |
download | hercules-33b8fd47955eeab26cede233b14d683b8e0491b8.tar.gz hercules-33b8fd47955eeab26cede233b14d683b8e0491b8.tar.bz2 hercules-33b8fd47955eeab26cede233b14d683b8e0491b8.tar.xz hercules-33b8fd47955eeab26cede233b14d683b8e0491b8.zip |
* Fixed alot of memory leaks
* Added stray memory cleaning routine to db.c
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/branches/stable@1275 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/char_sql')
-rw-r--r-- | src/char_sql/char.c | 9 | ||||
-rw-r--r-- | src/char_sql/int_guild.c | 29 | ||||
-rw-r--r-- | src/char_sql/int_guild.h | 1 | ||||
-rw-r--r-- | src/char_sql/int_party.c | 4 | ||||
-rw-r--r-- | src/char_sql/int_party.h | 1 | ||||
-rw-r--r-- | src/char_sql/int_pet.c | 4 | ||||
-rw-r--r-- | src/char_sql/int_pet.h | 1 | ||||
-rw-r--r-- | src/char_sql/int_storage.c | 7 | ||||
-rw-r--r-- | src/char_sql/int_storage.h | 1 | ||||
-rw-r--r-- | src/char_sql/inter.c | 20 | ||||
-rw-r--r-- | src/char_sql/inter.h | 2 |
11 files changed, 78 insertions, 1 deletions
diff --git a/src/char_sql/char.c b/src/char_sql/char.c index 78467b579..6b122974f 100644 --- a/src/char_sql/char.c +++ b/src/char_sql/char.c @@ -3134,6 +3134,12 @@ int char_lan_config_read(const char *lancfgName){ return 0; } +static int char_db_final(void *key,void *data,va_list ap) +{ + struct mmo_charstatus *p = data; + if (p) aFree(p); + return 0; +} void do_final(void) { printf("Doing final stage...\n"); //mmo_char_sync(); @@ -3162,9 +3168,12 @@ void do_final(void) { delete_session(login_fd); delete_session(char_fd); + numdb_final(char_db_, char_db_final); + exit_dbn(); mysql_close(&mysql_handle); mysql_close(&lmysql_handle); + timer_final(); printf("ok! all done...\n"); } diff --git a/src/char_sql/int_guild.c b/src/char_sql/int_guild.c index 2f294bade..4961fd933 100644 --- a/src/char_sql/int_guild.c +++ b/src/char_sql/int_guild.c @@ -709,6 +709,35 @@ int inter_guild_sql_init() return 0; } +int guild_expcache_db_final (void *k, void *data, va_list ap) { return 0; } +int guild_infoevent_db_final (void *k, void *data, va_list ap) { return 0; } +int guild_castleinfoevent_db_final (void *k, void *data, va_list ap) { return 0; } +int guild_db_final (void *k, void *data, va_list ap) +{ + struct guild *g = data; + if (g) aFree(g); + return 0; +} +int castle_db_final (void *k, void *data, va_list ap) +{ + struct guild_castle *gc = data; + if (gc) aFree(gc); + return 0; +} +void inter_guild_sql_final() +{ + if (guild_pt) aFree(guild_pt); + if (guild_pt2) aFree(guild_pt2); + if (guildcastle_pt) aFree(guildcastle_pt); + + numdb_final(guild_db_, guild_db_); + numdb_final(castle_db_, castle_db_final); + numdb_final(guild_expcache_db_, guild_expcache_db_final); + numdb_final(guild_infoevent_db_, guild_infoevent_db_final); + numdb_final(guild_castleinfoevent_db_, guild_castleinfoevent_db_final); + + return; +} // Get guild by its name struct guild* search_guildname(char *str) diff --git a/src/char_sql/int_guild.h b/src/char_sql/int_guild.h index 8f4203d7c..8257cf8f6 100644 --- a/src/char_sql/int_guild.h +++ b/src/char_sql/int_guild.h @@ -3,6 +3,7 @@ int inter_guild_parse_frommap(int fd); int inter_guild_sql_init(); +void inter_guild_sql_final(); int inter_guild_mapif_init(int fd); int inter_guild_leave(int guild_id,int account_id,int char_id); diff --git a/src/char_sql/int_party.c b/src/char_sql/int_party.c index 4cafa9f4d..03392feb6 100644 --- a/src/char_sql/int_party.c +++ b/src/char_sql/int_party.c @@ -237,6 +237,10 @@ int inter_party_sql_init(){ return 0; } +void inter_party_sql_final(){ + if (party_pt) aFree(party_pt); + return; +} // Search for the party according to its name diff --git a/src/char_sql/int_party.h b/src/char_sql/int_party.h index 04f71c881..686d70b04 100644 --- a/src/char_sql/int_party.h +++ b/src/char_sql/int_party.h @@ -3,6 +3,7 @@ int inter_party_parse_frommap(int fd); int inter_party_sql_init(); +void inter_party_sql_final(); int inter_party_leave(int party_id,int account_id); #endif diff --git a/src/char_sql/int_pet.c b/src/char_sql/int_pet.c index 35a7710a7..ea1fed67d 100644 --- a/src/char_sql/int_pet.c +++ b/src/char_sql/int_pet.c @@ -136,6 +136,10 @@ int inter_pet_sql_init(){ return 0; } +void inter_pet_sql_final(){ + if (pet_pt) aFree(pet_pt); + return; +} //---------------------------------- int inter_pet_delete(int pet_id){ printf("request delete pet: %d.......\n",pet_id); diff --git a/src/char_sql/int_pet.h b/src/char_sql/int_pet.h index b6e3f1bbf..39f127262 100644 --- a/src/char_sql/int_pet.h +++ b/src/char_sql/int_pet.h @@ -2,6 +2,7 @@ #define _INT_PET_H_ int inter_pet_init(); +void inter_pet_sql_final(); int inter_pet_save(); int inter_pet_delete(int pet_id); diff --git a/src/char_sql/int_storage.c b/src/char_sql/int_storage.c index 48f5e04a1..9bb5318c6 100644 --- a/src/char_sql/int_storage.c +++ b/src/char_sql/int_storage.c @@ -166,6 +166,13 @@ int inter_storage_sql_init(){ return 1; } +// storage data finalize +void inter_storage_sql_final() +{ + if (storage_pt) aFree(storage_pt); + if (guild_storage_pt) aFree(guild_storage_pt); + return; +} // q?f[^? int inter_storage_delete(int account_id) { diff --git a/src/char_sql/int_storage.h b/src/char_sql/int_storage.h index f9f37db3e..5541d1ed7 100644 --- a/src/char_sql/int_storage.h +++ b/src/char_sql/int_storage.h @@ -2,6 +2,7 @@ #define _INT_STORAGE_H_ int inter_storage_sql_init(); +void inter_storage_sql_final(); int inter_storage_delete(int account_id); int inter_guild_storage_delete(int guild_id); diff --git a/src/char_sql/inter.c b/src/char_sql/inter.c index a8e0d4f44..13ce0acbe 100644 --- a/src/char_sql/inter.c +++ b/src/char_sql/inter.c @@ -290,12 +290,32 @@ int inter_init(const char *file) inter_pet_sql_init(); inter_accreg_sql_init(); + atexit(inter_final); + //printf ("interserver timer initializing : %d sec...\n",autosave_interval); //i=add_timer_interval(gettick()+autosave_interval,inter_save_timer,0,0,autosave_interval); return 0; } +// finalize +int wis_db_final (void *k, void *data, va_list ap) { + struct WisData *p = data; + if (p) aFree(p); + return 0; +} +void inter_final() { + numdb_final(wis_db, wis_db_final); + + inter_guild_sql_final(); + inter_storage_sql_final(); + inter_party_sql_final(); + inter_pet_sql_final(); + + if (accreg_pt) aFree(accreg_pt); + return; +} + int inter_mapif_init(int fd) { inter_guild_mapif_init(fd); diff --git a/src/char_sql/inter.h b/src/char_sql/inter.h index 4b61b69c5..1e6a26dce 100644 --- a/src/char_sql/inter.h +++ b/src/char_sql/inter.h @@ -2,10 +2,10 @@ #define _INTER_H_ int inter_init(const char *file); +void inter_final(); int inter_parse_frommap(int fd); int inter_mapif_init(int fd); - int inter_check_length(int fd,int length); int inter_log(char *fmt,...); |