summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/map/guild.c16
-rw-r--r--src/map/pc_groups.c14
-rw-r--r--src/map/script.c32
-rw-r--r--src/map/skill.c17
4 files changed, 20 insertions, 59 deletions
diff --git a/src/map/guild.c b/src/map/guild.c
index 335d77301..5a5f72ea4 100644
--- a/src/map/guild.c
+++ b/src/map/guild.c
@@ -1914,12 +1914,6 @@ bool guild_isallied(int guild_id, int guild_id2)
return( i < MAX_GUILDALLIANCE && g->alliance[i].opposition == 0 );
}
-static int guild_infoevent_db_final(DBKey key,void *data,va_list ap)
-{
- aFree(data);
- return 0;
-}
-
static int guild_expcache_db_final(DBKey key,void *data,va_list ap)
{
ers_free(expcache_ers, data);
@@ -1940,9 +1934,9 @@ void do_init_guild(void)
guild_db=idb_alloc(DB_OPT_RELEASE_DATA);
castle_db=idb_alloc(DB_OPT_BASE);
guild_expcache_db=idb_alloc(DB_OPT_BASE);
- guild_infoevent_db=idb_alloc(DB_OPT_BASE);
+ guild_infoevent_db=idb_alloc(DB_OPT_BASE|DB_OPT_RELEASE_DATA);
expcache_ers = ers_new(sizeof(struct guild_expcache));
- guild_castleinfoevent_db=idb_alloc(DB_OPT_BASE);
+ guild_castleinfoevent_db=idb_alloc(DB_OPT_BASE|DB_OPT_RELEASE_DATA);
sv_readdb(db_path, "castle_db.txt", ',', 4, 5, -1, &guild_read_castledb);
@@ -1957,10 +1951,10 @@ void do_init_guild(void)
void do_final_guild(void)
{
- guild_db->destroy(guild_db,NULL);
+ db_destroy(guild_db);
castle_db->destroy(castle_db,guild_castle_db_final);
guild_expcache_db->destroy(guild_expcache_db,guild_expcache_db_final);
- guild_infoevent_db->destroy(guild_infoevent_db,guild_infoevent_db_final);
- guild_castleinfoevent_db->destroy(guild_castleinfoevent_db,guild_infoevent_db_final);
+ db_destroy(guild_infoevent_db);
+ db_destroy(guild_castleinfoevent_db);
ers_destroy(expcache_ers);
}
diff --git a/src/map/pc_groups.c b/src/map/pc_groups.c
index 8d35a0013..379968c79 100644
--- a/src/map/pc_groups.c
+++ b/src/map/pc_groups.c
@@ -422,29 +422,19 @@ int pc_group_id2level(int group_id)
*/
void do_init_pc_groups(void)
{
- pc_group_db = idb_alloc(DB_OPT_BASE);
+ pc_group_db = idb_alloc(DB_OPT_RELEASE_DATA);
pc_groupname_db = stridb_alloc(DB_OPT_DUP_KEY, 0);
read_config();
}
/**
- * DBApply helper function for do_final_pc_groups
- * @private
- */
-static int group_db_free(DBKey key, void *data, va_list args)
-{
- aFree((GroupSettings*)data);
- return 1;
-}
-
-/**
* Finalize PC Groups: free DBMaps and config.
* @public
*/
void do_final_pc_groups(void)
{
if (pc_group_db != NULL)
- pc_group_db->destroy(pc_group_db, group_db_free);
+ db_destroy(pc_group_db);
if (pc_groupname_db != NULL )
db_destroy(pc_groupname_db);
destroy_config();
diff --git a/src/map/script.c b/src/map/script.c
index 8fdefe2c2..5f84aa2d9 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -3634,24 +3634,10 @@ int script_config_read(char *cfgName)
return 0;
}
-static int do_final_userfunc_sub (DBKey key,void *data,va_list ap)
+static int db_script_free_code_sub(DBKey key, void *data, va_list ap)
{
- struct script_code *code = (struct script_code *)data;
- if(code){
- script_free_vars( &code->script_vars );
- aFree( code->script_buf );
- aFree( code );
- }
- return 0;
-}
-
-static int do_final_autobonus_sub (DBKey key,void *data,va_list ap)
-{
- struct script_code *script = (struct script_code *)data;
-
- if( script )
- script_free_code(script);
-
+ if (data)
+ script_free_code(data);
return 0;
}
@@ -3807,9 +3793,9 @@ int do_final_script()
mapreg_final();
- scriptlabel_db->destroy(scriptlabel_db,NULL);
- userfunc_db->destroy(userfunc_db,do_final_userfunc_sub);
- autobonus_db->destroy(autobonus_db, do_final_autobonus_sub);
+ db_destroy(scriptlabel_db);
+ userfunc_db->destroy(userfunc_db, db_script_free_code_sub);
+ autobonus_db->destroy(autobonus_db, db_script_free_code_sub);
if(sleep_db) {
struct linkdb_node *n = (struct linkdb_node *)sleep_db;
while(n) {
@@ -3833,7 +3819,7 @@ int do_final_script()
int do_init_script()
{
userfunc_db=strdb_alloc(DB_OPT_DUP_KEY,0);
- scriptlabel_db=strdb_alloc((DBOptions)(DB_OPT_DUP_KEY|DB_OPT_ALLOW_NULL_DATA),50);
+ scriptlabel_db=strdb_alloc(DB_OPT_DUP_KEY|DB_OPT_ALLOW_NULL_DATA,50);
autobonus_db = strdb_alloc(DB_OPT_DUP_KEY,0);
mapreg_init();
@@ -3843,8 +3829,8 @@ int do_init_script()
int script_reload()
{
- userfunc_db->clear(userfunc_db,do_final_userfunc_sub);
- scriptlabel_db->clear(scriptlabel_db, NULL);
+ userfunc_db->clear(userfunc_db, db_script_free_code_sub);
+ db_clear(scriptlabel_db);
if(sleep_db) {
struct linkdb_node *n = (struct linkdb_node *)sleep_db;
diff --git a/src/map/skill.c b/src/map/skill.c
index 6a87829d2..ffbb91275 100644
--- a/src/map/skill.c
+++ b/src/map/skill.c
@@ -14723,10 +14723,9 @@ int skill_blockpc_end(int tid, unsigned int tick, int id, intptr_t data)
}
cursor++;
}
- if( cursor == 0 ) {
+ if( cursor == 0 )
idb_remove(skillcd_db,sd->status.char_id);
- aFree(cd);
- } else
+ else
cd->cursor = cursor;
}
@@ -15688,7 +15687,7 @@ int do_init_skill (void)
group_db = idb_alloc(DB_OPT_BASE);
skillunit_db = idb_alloc(DB_OPT_BASE);
- skillcd_db = idb_alloc(DB_OPT_BASE);
+ skillcd_db = idb_alloc(DB_OPT_RELEASE_DATA);
skill_unit_ers = ers_new(sizeof(struct skill_unit_group));
skill_timer_ers = ers_new(sizeof(struct skill_timerskill));
@@ -15703,20 +15702,12 @@ int do_init_skill (void)
return 0;
}
-int skillcd_db_final(DBKey key, void *data, va_list args)
-{
- struct skillcd *s = (struct skillcd*)data;
- if( s != NULL)
- aFree(s);
- return 0;
-}
-
int do_final_skill(void)
{
db_destroy(skilldb_name2id);
db_destroy(group_db);
db_destroy(skillunit_db);
- skillcd_db->destroy(skillcd_db, skillcd_db_final);
+ db_destroy(skillcd_db);
ers_destroy(skill_unit_ers);
ers_destroy(skill_timer_ers);
return 0;