From 12e0b7a12a177cee9ab6e1f16d032d05da47a429 Mon Sep 17 00:00:00 2001 From: gepard1984 Date: Thu, 1 Mar 2012 23:21:45 +0000 Subject: 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 --- src/map/script.c | 32 +++++++++----------------------- 1 file changed, 9 insertions(+), 23 deletions(-) (limited to 'src/map/script.c') 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; -- cgit v1.2.3-60-g2f50