From 1de237a502ceee96df7091c2df4492b8bc08b2c5 Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Sat, 7 Nov 2015 17:38:22 +0100 Subject: node: Add json_node_ref() and json_node_unref() Add reference counting semantics to JsonNode, in addition to the existing init/unset and alloc/free semantics. json_node_free() must only be used with nodes allocated using json_node_alloc(). json_node_unref() may be used with all nodes (if correctly paired; it may be paired with json_node_alloc()). It is not valid to call json_node_free() on a node whose reference count is not 1. https://bugzilla.gnome.org/show_bug.cgi?id=756121 --- json-glib/json-array.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'json-glib/json-array.c') diff --git a/json-glib/json-array.c b/json-glib/json-array.c index 05cde4a..cc9c979 100644 --- a/json-glib/json-array.c +++ b/json-glib/json-array.c @@ -124,7 +124,7 @@ json_array_unref (JsonArray *array) guint i; for (i = 0; i < array->elements->len; i++) - json_node_free (g_ptr_array_index (array->elements, i)); + json_node_unref (g_ptr_array_index (array->elements, i)); g_ptr_array_free (array->elements, TRUE); array->elements = NULL; @@ -217,7 +217,7 @@ json_array_get_elements (JsonArray *array) * element at @index_ inside a #JsonArray * * Return value: (transfer full): a copy of the #JsonNode at the requested - * index. Use json_node_free() when done. + * index. Use json_node_unref() when done. * * Since: 0.6 */ @@ -706,7 +706,7 @@ json_array_remove_element (JsonArray *array, g_return_if_fail (array != NULL); g_return_if_fail (index_ < array->elements->len); - json_node_free (g_ptr_array_remove_index (array->elements, index_)); + json_node_unref (g_ptr_array_remove_index (array->elements, index_)); } /** -- cgit v1.2.1