diff options
author | jaBote <j@bot.e> | 2013-05-03 01:45:50 +0200 |
---|---|---|
committer | jaBote <j@bot.e> | 2013-05-03 01:45:50 +0200 |
commit | 1e5e8f5f42abb2cd42ad7ecf8e07439b8a1c570b (patch) | |
tree | c8825cc2dc141d91fe1fcc52739a0e79a89c80e9 /src/common/db.c | |
parent | f41dea469a52213acfde4f4ea5e8d7bbbd869bed (diff) | |
parent | 274bfc3b06616ea03c467d8eed23fae61c72fe18 (diff) | |
download | hercules-1e5e8f5f42abb2cd42ad7ecf8e07439b8a1c570b.tar.gz hercules-1e5e8f5f42abb2cd42ad7ecf8e07439b8a1c570b.tar.bz2 hercules-1e5e8f5f42abb2cd42ad7ecf8e07439b8a1c570b.tar.xz hercules-1e5e8f5f42abb2cd42ad7ecf8e07439b8a1c570b.zip |
Merge branch 'master' of https://github.com/HerculesWS/Hercules
Diffstat (limited to 'src/common/db.c')
-rw-r--r-- | src/common/db.c | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/src/common/db.c b/src/common/db.c index 204c6d2ea..7ac9b2dc7 100644 --- a/src/common/db.c +++ b/src/common/db.c @@ -47,6 +47,7 @@ * - create a db that organizes itself by splaying * * HISTORY: + * 2013/04/27 - Added ERS to speed up iterator memory allocation [Ind/Hercules] * 2012/03/09 - Added enum for data types (int, uint, void*) * 2008/02/19 - Fixed db_obj_get not handling deleted entries correctly. * 2007/11/09 - Added an iterator to the database. @@ -319,6 +320,10 @@ static struct db_stats { #define DB_COUNTSTAT(token) #endif /* !defined(DB_ENABLE_STATS) */ +/* [Ind/Hercules] */ +struct eri *db_iterator_ers; +struct eri *db_alloc_ers; + /*****************************************************************************\ * (2) Section of private functions used by the database system. * * db_rotate_left - Rotate a tree node to the left. * @@ -1366,7 +1371,7 @@ void dbit_obj_destroy(DBIterator* self) // unlock the database db_free_unlock(it->db); // free iterator - aFree(self); + ers_free(db_iterator_ers,self); } /** @@ -1384,7 +1389,7 @@ static DBIterator* db_obj_iterator(DBMap* self) DBIterator_impl* it; DB_COUNTSTAT(db_iterator); - CREATE(it, struct DBIterator_impl, 1); + it = ers_alloc(db_iterator_ers, struct DBIterator_impl); /* Interface of the iterator **/ it->vtable.first = dbit_obj_first; it->vtable.last = dbit_obj_last; @@ -2127,7 +2132,7 @@ static int db_obj_vdestroy(DBMap* self, DBApply func, va_list args) db->free_max = 0; ers_destroy(db->nodes); db_free_unlock(db); - aFree(db); + ers_free(db_alloc_ers, db); return sum; } @@ -2409,7 +2414,7 @@ DBMap* db_alloc(const char *file, int line, DBType type, DBOptions options, unsi case DB_ISTRING: DB_COUNTSTAT(db_istring_alloc); break; } #endif /* DB_ENABLE_STATS */ - CREATE(db, struct DBMap_impl, 1); + db = ers_alloc(db_alloc_ers, struct DBMap_impl); options = db_fix_options(type, options); /* Interface of the database */ @@ -2602,8 +2607,9 @@ void* db_data2ptr(DBData *data) * @public * @see #db_final(void) */ -void db_init(void) -{ +void db_init(void) { + db_iterator_ers = ers_new(sizeof(struct DBIterator_impl),"db.c::db_iterator_ers",ERS_OPT_NONE); + db_alloc_ers = ers_new(sizeof(struct DBMap_impl),"db.c::db_alloc_ers",ERS_OPT_NONE); DB_COUNTSTAT(db_init); } @@ -2696,6 +2702,8 @@ void db_final(void) stats.db_data2ui, stats.db_data2ptr, stats.db_init, stats.db_final); #endif /* DB_ENABLE_STATS */ + ers_destroy(db_iterator_ers); + ers_destroy(db_alloc_ers); } // Link DB System - jAthena |