summaryrefslogtreecommitdiff
path: root/src/map/script.c
diff options
context:
space:
mode:
authorgepard1984 <gepard1984@54d463be-8e91-2dee-dedb-b68131a5f0ec>2012-03-01 23:21:45 +0000
committergepard1984 <gepard1984@54d463be-8e91-2dee-dedb-b68131a5f0ec>2012-03-01 23:21:45 +0000
commit12e0b7a12a177cee9ab6e1f16d032d05da47a429 (patch)
tree7d5ffe863344db9fb82eef811107e5805ba5fafe /src/map/script.c
parent983fcb851918b1ab40c182f6719b7e800fe0d643 (diff)
downloadhercules-12e0b7a12a177cee9ab6e1f16d032d05da47a429.tar.gz
hercules-12e0b7a12a177cee9ab6e1f16d032d05da47a429.tar.bz2
hercules-12e0b7a12a177cee9ab6e1f16d032d05da47a429.tar.xz
hercules-12e0b7a12a177cee9ab6e1f16d032d05da47a429.zip
Enabled `DB_OPT_RELEASE_DATA` for several `DBMap`s to simplify data freeing.
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@15644 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map/script.c')
-rw-r--r--src/map/script.c32
1 files changed, 9 insertions, 23 deletions
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;