forked from enlightenment/efl
Add rbtree destructor without tree reorder and use it.
SVN revision: 36188
This commit is contained in:
parent
476222cc6c
commit
8acad8a50e
|
@ -50,6 +50,9 @@ typedef Eina_Rbtree_Direction (*Eina_Rbtree_Cmp_Node_Cb)(const Eina_Rbtree *left
|
|||
typedef int (*Eina_Rbtree_Cmp_Key_Cb)(const Eina_Rbtree *node, const void *key, int length, void *data);
|
||||
#define EINA_RBTREE_CMP_KEY_CB(Function) ((Eina_Rbtree_Cmp_Key_Cb) Function)
|
||||
|
||||
typedef void (*Eina_Rbtree_Free_Cb)(Eina_Rbtree *node);
|
||||
#define EINA_RBTREE_FREE_CB(Function) ((Eina_Rbtree_Free_Cb) Function)
|
||||
|
||||
EAPI Eina_Rbtree *eina_rbtree_inline_insert(Eina_Rbtree *root, Eina_Rbtree *node, Eina_Rbtree_Cmp_Node_Cb cmp, const void *data);
|
||||
EAPI Eina_Rbtree *eina_rbtree_inline_remove(Eina_Rbtree *root, Eina_Rbtree *node, Eina_Rbtree_Cmp_Node_Cb cmp, const void *data);
|
||||
|
||||
|
@ -59,6 +62,8 @@ EAPI Eina_Iterator *eina_rbtree_iterator_prefix(const Eina_Rbtree *root);
|
|||
EAPI Eina_Iterator *eina_rbtree_iterator_infix(const Eina_Rbtree *root);
|
||||
EAPI Eina_Iterator *eina_rbtree_iterator_postfix(const Eina_Rbtree *root);
|
||||
|
||||
EAPI void eina_rbtree_delete(Eina_Rbtree *root, Eina_Rbtree_Free_Cb func);
|
||||
|
||||
#include "eina_inline_rbtree.x"
|
||||
|
||||
#endif
|
||||
|
|
|
@ -447,3 +447,13 @@ eina_rbtree_iterator_postfix(const Eina_Rbtree *root)
|
|||
return _eina_rbtree_iterator_build(root, EINA_RBTREE_ITERATOR_POSTFIX_MASK);
|
||||
}
|
||||
|
||||
EAPI void
|
||||
eina_rbtree_delete(Eina_Rbtree *root, Eina_Rbtree_Free_Cb func)
|
||||
{
|
||||
if (!root) return ;
|
||||
|
||||
eina_rbtree_delete(root->son[0], func);
|
||||
eina_rbtree_delete(root->son[1], func);
|
||||
func(root);
|
||||
}
|
||||
|
||||
|
|
|
@ -128,6 +128,19 @@ _eina_stringshare_node(const Eina_Stringshare_Head *left, const Eina_Stringshare
|
|||
return EINA_RBTREE_RIGHT;
|
||||
}
|
||||
|
||||
static void
|
||||
_eina_stringshare_head_free(Eina_Stringshare_Head *ed)
|
||||
{
|
||||
while (ed->head)
|
||||
{
|
||||
Eina_Stringshare_Node *el = ed->head;
|
||||
|
||||
ed->head = ed->head->next;
|
||||
if (el->begin == EINA_FALSE) free(el);
|
||||
}
|
||||
free(ed);
|
||||
}
|
||||
|
||||
/**
|
||||
* @endcond
|
||||
*/
|
||||
|
@ -221,23 +234,7 @@ eina_stringshare_shutdown()
|
|||
/* remove any string still in the table */
|
||||
for (i = 0; i < EINA_STRINGSHARE_BUCKETS; i++)
|
||||
{
|
||||
Eina_Stringshare_Head *ed = share->buckets[i];
|
||||
Eina_Stringshare_Head *save;
|
||||
|
||||
while (ed)
|
||||
{
|
||||
save = ed;
|
||||
ed = (Eina_Stringshare_Head*) eina_rbtree_inline_remove(&ed->node, &ed->node,
|
||||
EINA_RBTREE_CMP_NODE_CB(_eina_stringshare_node), NULL);
|
||||
while (save->head)
|
||||
{
|
||||
Eina_Stringshare_Node *el = save->head;
|
||||
|
||||
save->head = el->next;
|
||||
if (el->begin == EINA_FALSE) free(el);
|
||||
}
|
||||
free(save);
|
||||
}
|
||||
eina_rbtree_delete(share->buckets[i], EINA_RBTREE_FREE_CB(_eina_stringshare_head_free));
|
||||
share->buckets[i] = NULL;
|
||||
}
|
||||
free(share);
|
||||
|
|
Loading…
Reference in New Issue