Browse Source

ckdb - release the knode item back to the free list when removing an item from a tree

master
kanoi 9 years ago
parent
commit
4ac4a35648
  1. 2
      src/ckdb.h
  2. 14
      src/ktree.c

2
src/ckdb.h

@ -51,7 +51,7 @@
#define DB_VLOCK "1" #define DB_VLOCK "1"
#define DB_VERSION "1.0.4" #define DB_VERSION "1.0.4"
#define CKDB_VERSION DB_VERSION"-1.902" #define CKDB_VERSION DB_VERSION"-1.910"
#define WHERE_FFL " - from %s %s() line %d" #define WHERE_FFL " - from %s %s() line %d"
#define WHERE_FFL_HERE __FILE__, __func__, __LINE__ #define WHERE_FFL_HERE __FILE__, __func__, __LINE__

14
src/ktree.c

@ -1053,11 +1053,21 @@ DBG("@remove after balance=%d :(\n", (int)cmp);
return; return;
} }
void _remove_from_ktree_free(K_TREE *root, K_ITEM *data, bool chklock, KTREE_FFL_ARGS) void _remove_from_ktree_free(K_TREE *tree, K_ITEM *data, bool chklock, KTREE_FFL_ARGS)
{ {
K_TREE_CTX ctx[1]; K_TREE_CTX ctx[1];
K_NODE *knode;
K_ITEM *kitem;
_remove_from_ktree(root, data, ctx, chklock, KTREE_FFL_PASS); _remove_from_ktree(tree, data, ctx, chklock, KTREE_FFL_PASS);
if (ctx[0]) {
knode = (K_NODE *)(ctx[0]);
kitem = knode->kitem;
// _nolock since _remove_from_ktree() already tested it
k_unlink_item_nolock(tree->node_store, kitem);
k_add_head_nolock(tree->node_free, kitem);
}
} }
static void free_ktree_sub(K_NODE *knode, void (*free_funct)(void *)) static void free_ktree_sub(K_NODE *knode, void (*free_funct)(void *))

Loading…
Cancel
Save