Enabled DB_OPT_RELEASE_DATA
for several DBMap
s to simplify data freeing.
git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@15644 54d463be-8e91-2dee-dedb-b68131a5f0ec
This commit is contained in:
parent
57de7584e8
commit
17bb9ae684
@ -1914,12 +1914,6 @@ bool guild_isallied(int guild_id, int guild_id2)
|
|||||||
return( i < MAX_GUILDALLIANCE && g->alliance[i].opposition == 0 );
|
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)
|
static int guild_expcache_db_final(DBKey key,void *data,va_list ap)
|
||||||
{
|
{
|
||||||
ers_free(expcache_ers, data);
|
ers_free(expcache_ers, data);
|
||||||
@ -1940,9 +1934,9 @@ void do_init_guild(void)
|
|||||||
guild_db=idb_alloc(DB_OPT_RELEASE_DATA);
|
guild_db=idb_alloc(DB_OPT_RELEASE_DATA);
|
||||||
castle_db=idb_alloc(DB_OPT_BASE);
|
castle_db=idb_alloc(DB_OPT_BASE);
|
||||||
guild_expcache_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));
|
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);
|
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)
|
void do_final_guild(void)
|
||||||
{
|
{
|
||||||
guild_db->destroy(guild_db,NULL);
|
db_destroy(guild_db);
|
||||||
castle_db->destroy(castle_db,guild_castle_db_final);
|
castle_db->destroy(castle_db,guild_castle_db_final);
|
||||||
guild_expcache_db->destroy(guild_expcache_db,guild_expcache_db_final);
|
guild_expcache_db->destroy(guild_expcache_db,guild_expcache_db_final);
|
||||||
guild_infoevent_db->destroy(guild_infoevent_db,guild_infoevent_db_final);
|
db_destroy(guild_infoevent_db);
|
||||||
guild_castleinfoevent_db->destroy(guild_castleinfoevent_db,guild_infoevent_db_final);
|
db_destroy(guild_castleinfoevent_db);
|
||||||
ers_destroy(expcache_ers);
|
ers_destroy(expcache_ers);
|
||||||
}
|
}
|
||||||
|
@ -422,21 +422,11 @@ int pc_group_id2level(int group_id)
|
|||||||
*/
|
*/
|
||||||
void do_init_pc_groups(void)
|
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);
|
pc_groupname_db = stridb_alloc(DB_OPT_DUP_KEY, 0);
|
||||||
read_config();
|
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.
|
* Finalize PC Groups: free DBMaps and config.
|
||||||
* @public
|
* @public
|
||||||
@ -444,7 +434,7 @@ static int group_db_free(DBKey key, void *data, va_list args)
|
|||||||
void do_final_pc_groups(void)
|
void do_final_pc_groups(void)
|
||||||
{
|
{
|
||||||
if (pc_group_db != NULL)
|
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 )
|
if (pc_groupname_db != NULL )
|
||||||
db_destroy(pc_groupname_db);
|
db_destroy(pc_groupname_db);
|
||||||
destroy_config();
|
destroy_config();
|
||||||
|
@ -3634,24 +3634,10 @@ int script_config_read(char *cfgName)
|
|||||||
return 0;
|
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 (data)
|
||||||
if(code){
|
script_free_code(data);
|
||||||
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);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3807,9 +3793,9 @@ int do_final_script()
|
|||||||
|
|
||||||
mapreg_final();
|
mapreg_final();
|
||||||
|
|
||||||
scriptlabel_db->destroy(scriptlabel_db,NULL);
|
db_destroy(scriptlabel_db);
|
||||||
userfunc_db->destroy(userfunc_db,do_final_userfunc_sub);
|
userfunc_db->destroy(userfunc_db, db_script_free_code_sub);
|
||||||
autobonus_db->destroy(autobonus_db, do_final_autobonus_sub);
|
autobonus_db->destroy(autobonus_db, db_script_free_code_sub);
|
||||||
if(sleep_db) {
|
if(sleep_db) {
|
||||||
struct linkdb_node *n = (struct linkdb_node *)sleep_db;
|
struct linkdb_node *n = (struct linkdb_node *)sleep_db;
|
||||||
while(n) {
|
while(n) {
|
||||||
@ -3833,7 +3819,7 @@ int do_final_script()
|
|||||||
int do_init_script()
|
int do_init_script()
|
||||||
{
|
{
|
||||||
userfunc_db=strdb_alloc(DB_OPT_DUP_KEY,0);
|
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);
|
autobonus_db = strdb_alloc(DB_OPT_DUP_KEY,0);
|
||||||
|
|
||||||
mapreg_init();
|
mapreg_init();
|
||||||
@ -3843,8 +3829,8 @@ int do_init_script()
|
|||||||
|
|
||||||
int script_reload()
|
int script_reload()
|
||||||
{
|
{
|
||||||
userfunc_db->clear(userfunc_db,do_final_userfunc_sub);
|
userfunc_db->clear(userfunc_db, db_script_free_code_sub);
|
||||||
scriptlabel_db->clear(scriptlabel_db, NULL);
|
db_clear(scriptlabel_db);
|
||||||
|
|
||||||
if(sleep_db) {
|
if(sleep_db) {
|
||||||
struct linkdb_node *n = (struct linkdb_node *)sleep_db;
|
struct linkdb_node *n = (struct linkdb_node *)sleep_db;
|
||||||
|
@ -14723,10 +14723,9 @@ int skill_blockpc_end(int tid, unsigned int tick, int id, intptr_t data)
|
|||||||
}
|
}
|
||||||
cursor++;
|
cursor++;
|
||||||
}
|
}
|
||||||
if( cursor == 0 ) {
|
if( cursor == 0 )
|
||||||
idb_remove(skillcd_db,sd->status.char_id);
|
idb_remove(skillcd_db,sd->status.char_id);
|
||||||
aFree(cd);
|
else
|
||||||
} else
|
|
||||||
cd->cursor = cursor;
|
cd->cursor = cursor;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -15688,7 +15687,7 @@ int do_init_skill (void)
|
|||||||
|
|
||||||
group_db = idb_alloc(DB_OPT_BASE);
|
group_db = idb_alloc(DB_OPT_BASE);
|
||||||
skillunit_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_unit_ers = ers_new(sizeof(struct skill_unit_group));
|
||||||
skill_timer_ers = ers_new(sizeof(struct skill_timerskill));
|
skill_timer_ers = ers_new(sizeof(struct skill_timerskill));
|
||||||
|
|
||||||
@ -15703,20 +15702,12 @@ int do_init_skill (void)
|
|||||||
return 0;
|
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)
|
int do_final_skill(void)
|
||||||
{
|
{
|
||||||
db_destroy(skilldb_name2id);
|
db_destroy(skilldb_name2id);
|
||||||
db_destroy(group_db);
|
db_destroy(group_db);
|
||||||
db_destroy(skillunit_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_unit_ers);
|
||||||
ers_destroy(skill_timer_ers);
|
ers_destroy(skill_timer_ers);
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user