summaryrefslogtreecommitdiff
path: root/src/core/node.c
diff options
context:
space:
mode:
authorDaniel Silverstone <dsilvers@netsurf-browser.org>2012-03-28 19:33:33 +0000
committerDaniel Silverstone <dsilvers@netsurf-browser.org>2012-03-28 19:33:33 +0000
commit1aa65d46aa7c2861612e912c0ce44f53d5b35df7 (patch)
tree8e40217b9719be155e97e030a7980d2bc0e471d7 /src/core/node.c
parentfea71815737d9da24f66c440f02aa16ee256c770 (diff)
downloadlibdom-1aa65d46aa7c2861612e912c0ce44f53d5b35df7.tar.gz
libdom-1aa65d46aa7c2861612e912c0ce44f53d5b35df7.tar.bz2
Promote ref/unref in dom_node to be inlines.
svn path=/trunk/libdom/; revision=13761
Diffstat (limited to 'src/core/node.c')
-rw-r--r--src/core/node.c48
1 files changed, 7 insertions, 41 deletions
diff --git a/src/core/node.c b/src/core/node.c
index 4509f10..628c7c6 100644
--- a/src/core/node.c
+++ b/src/core/node.c
@@ -198,7 +198,7 @@ dom_exception _dom_node_initialise(dom_node_internal *node,
node->user_data = NULL;
- node->refcnt = 1;
+ node->base.refcnt = 1;
list_init(&node->pending_list);
if (node->type != DOM_DOCUMENT_NODE) {
@@ -279,48 +279,12 @@ void _dom_node_finalise(dom_node_internal *node)
}
}
-/**
- * Claim a reference on a DOM node
- *
- * \param node The node to claim a reference on
- */
-struct dom_node *_dom_node_ref(dom_node_internal *node)
-{
- if (node != NULL)
- node->refcnt++;
-
- return (struct dom_node *)node;
-}
-
/* ---------------------------------------------------------------------*/
/* The public virtual function of this interface Node */
/**
- * Release a reference on a DOM node
- *
- * \param node The node to release the reference from
- *
- * If the reference count reaches zero and the node is not part of any
- * document, any memory claimed by the node will be released.
- *
- * If the parent of the node is NULL but the reference count does not reach
- * zero, this means we should put this node to the document's deletion pending
- * list. When the refcnt reach zero, we delete it.
- */
-void _dom_node_unref(dom_node_internal *node)
-{
- if (node == NULL)
- return;
-
- if (node->refcnt > 0)
- node->refcnt--;
-
- dom_node_try_destroy(node);
-}
-
-/**
* Retrieve the name of a DOM node
*
* \param node The node to retrieve the name of
@@ -1872,7 +1836,7 @@ dom_exception _dom_node_copy_internal(dom_node_internal *old,
new->prefix = NULL;
new->user_data = NULL;
- new->refcnt = 1;
+ new->base.refcnt = 1;
list_init(&new->pending_list);
@@ -2214,13 +2178,13 @@ dom_exception _dom_merge_adjacent_text(dom_node_internal *p,
*
* @note: Owning a node does not means this node's refcnt is above zero.
*/
-void _dom_node_try_destroy(dom_node_internal *node)
+dom_exception _dom_node_try_destroy(dom_node_internal *node)
{
if (node == NULL)
- return;
+ return DOM_NO_ERR;
if (node->parent == NULL) {
- if (node->refcnt == 0) {
+ if (node->base.refcnt == 0) {
dom_node_destroy(node);
} else if (node->pending_list.prev == &node->pending_list){
assert (node->pending_list.next == &node->pending_list);
@@ -2228,6 +2192,8 @@ void _dom_node_try_destroy(dom_node_internal *node)
&node->pending_list);
}
}
+
+ return DOM_NO_ERR;
}
/**