summaryrefslogtreecommitdiff
path: root/src/common/db.c
diff options
context:
space:
mode:
authorshennetsind <ind@henn.et>2013-05-17 22:03:06 -0300
committershennetsind <ind@henn.et>2013-05-17 22:03:06 -0300
commit21bbfad48084190b8a6881ee3b277993418a5137 (patch)
tree2c8cf1d4a83bb0a7bea2a7e81c003fc240185207 /src/common/db.c
parent104bb6c05dc8effef9db715f0b708d4548e10010 (diff)
parentb3bc657a44a9fbdd1730f569855e25ccd0f8dd01 (diff)
downloadhercules-21bbfad48084190b8a6881ee3b277993418a5137.tar.gz
hercules-21bbfad48084190b8a6881ee3b277993418a5137.tar.bz2
hercules-21bbfad48084190b8a6881ee3b277993418a5137.tar.xz
hercules-21bbfad48084190b8a6881ee3b277993418a5137.zip
Follow up b3bc657a44a9fbdd1730f569855e25ccd0f8dd01
Adjusting it to the ERS modification, my IDE automatically fixed some indentation that i guess was accidentally removed. Signed-off-by: shennetsind <ind@henn.et>
Diffstat (limited to 'src/common/db.c')
-rw-r--r--src/common/db.c32
1 files changed, 26 insertions, 6 deletions
diff --git a/src/common/db.c b/src/common/db.c
index f2e69abbb..561371787 100644
--- a/src/common/db.c
+++ b/src/common/db.c
@@ -510,7 +510,7 @@ static void db_rebalance_erase(DBNode node, DBNode *root)
// put the right of 'node' in 'y'
y->right = node->right;
node->right->parent = y;
- // 'y' is a direct child of 'node'
+ // 'y' is a direct child of 'node'
} else {
x_parent = y;
}
@@ -2349,7 +2349,7 @@ DBHasher db_default_hash(DBType type)
DBReleaser db_default_release(DBType type, DBOptions options)
{
DB_COUNTSTAT(db_default_release);
- options = db_fix_options(type, options);
+ options = DB->fix_options(type, options);
if (options&DB_OPT_RELEASE_DATA) { // Release data, what about the key?
if (options&(DB_OPT_DUP_KEY|DB_OPT_RELEASE_KEY))
return &db_release_both; // Release both key and data
@@ -2416,7 +2416,7 @@ DBMap* db_alloc(const char *file, const char *func, int line, DBType type, DBOpt
#endif /* DB_ENABLE_STATS */
db = ers_alloc(db_alloc_ers, struct DBMap_impl);
- options = db_fix_options(type, options);
+ options = DB->fix_options(type, options);
/* Interface of the database */
db->vtable.iterator = db_obj_iterator;
db->vtable.exists = db_obj_exists;
@@ -2447,9 +2447,9 @@ DBMap* db_alloc(const char *file, const char *func, int line, DBType type, DBOpt
/* Other */
snprintf(ers_name, 50, "db_alloc:nodes:%s:%s:%d",func,file,line);
db->nodes = ers_new(sizeof(struct dbn),ers_name,ERS_OPT_WAIT|ERS_OPT_FREE_NAME);
- db->cmp = db_default_cmp(type);
- db->hash = db_default_hash(type);
- db->release = db_default_release(type, options);
+ db->cmp = DB->default_cmp(type);
+ db->hash = DB->default_hash(type);
+ db->release = DB->default_release(type, options);
for (i = 0; i < HASH_SIZE; i++)
db->ht[i] = NULL;
db->cache = NULL;
@@ -2829,3 +2829,23 @@ void linkdb_final( struct linkdb_node** head )
}
*head = NULL;
}
+void db_defaults(void) {
+ DB = &DB_s;
+ DB->alloc = db_alloc;
+ DB->custom_release = db_custom_release;
+ DB->data2i = db_data2i;
+ DB->data2ptr = db_data2ptr;
+ DB->data2ui = db_data2ui;
+ DB->default_cmp = db_default_cmp;
+ DB->default_hash = db_default_hash;
+ DB->default_release = db_default_release;
+ DB->final = db_final;
+ DB->fix_options = db_fix_options;
+ DB->i2data = db_i2data;
+ DB->i2key = db_i2key;
+ DB->init = db_init;
+ DB->ptr2data = db_ptr2data;
+ DB->str2key = db_str2key;
+ DB->ui2data = db_ui2data;
+ DB->ui2key = db_ui2key;
+}