summaryrefslogtreecommitdiff
path: root/json-glib/json-parser.c
diff options
context:
space:
mode:
authorPhilip Withnall <philip.withnall@collabora.co.uk>2015-11-07 17:38:22 +0100
committerEmmanuele Bassi <ebassi@gnome.org>2016-03-01 14:53:02 +0000
commit1de237a502ceee96df7091c2df4492b8bc08b2c5 (patch)
treec9f51fdc9c370b57abe75e97200b3747a5f326bb /json-glib/json-parser.c
parent58f479b60eb2db4c73605d469d68a8ffd8679327 (diff)
downloadjson-glib-1de237a502ceee96df7091c2df4492b8bc08b2c5.tar.gz
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
Diffstat (limited to 'json-glib/json-parser.c')
-rw-r--r--json-glib/json-parser.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/json-glib/json-parser.c b/json-glib/json-parser.c
index 8f1c40c..a7b1c32 100644
--- a/json-glib/json-parser.c
+++ b/json-glib/json-parser.c
@@ -134,7 +134,7 @@ json_parser_clear (JsonParser *parser)
if (priv->root)
{
- json_node_free (priv->root);
+ json_node_unref (priv->root);
priv->root = NULL;
}
}
@@ -553,7 +553,7 @@ json_parse_array (JsonParser *parser,
{
/* the json_parse_* functions will have set the error code */
json_array_unref (array);
- json_node_free (priv->current_node);
+ json_node_unref (priv->current_node);
priv->current_node = old_current;
return token;
@@ -585,8 +585,8 @@ json_parse_array (JsonParser *parser,
priv->error_code = JSON_PARSER_ERROR_TRAILING_COMMA;
json_array_unref (array);
- json_node_free (priv->current_node);
- json_node_free (element);
+ json_node_unref (priv->current_node);
+ json_node_unref (element);
priv->current_node = old_current;
return G_TOKEN_RIGHT_BRACE;
@@ -669,7 +669,7 @@ json_parse_object (JsonParser *parser,
priv->error_code = JSON_PARSER_ERROR_INVALID_BAREWORD;
json_object_unref (object);
- json_node_free (priv->current_node);
+ json_node_unref (priv->current_node);
priv->current_node = old_current;
return G_TOKEN_STRING;
@@ -685,7 +685,7 @@ json_parse_object (JsonParser *parser,
priv->error_code = JSON_PARSER_ERROR_EMPTY_MEMBER_NAME;
json_object_unref (object);
- json_node_free (priv->current_node);
+ json_node_unref (priv->current_node);
priv->current_node = old_current;
return G_TOKEN_STRING;
@@ -703,7 +703,7 @@ json_parse_object (JsonParser *parser,
g_free (name);
json_object_unref (object);
- json_node_free (priv->current_node);
+ json_node_unref (priv->current_node);
priv->current_node = old_current;
return ':';
@@ -739,7 +739,7 @@ json_parse_object (JsonParser *parser,
/* the json_parse_* functions will have set the error code */
g_free (name);
json_object_unref (object);
- json_node_free (priv->current_node);
+ json_node_unref (priv->current_node);
priv->current_node = old_current;
return token;
@@ -757,8 +757,8 @@ json_parse_object (JsonParser *parser,
priv->error_code = JSON_PARSER_ERROR_TRAILING_COMMA;
json_object_unref (object);
- json_node_free (member);
- json_node_free (priv->current_node);
+ json_node_unref (member);
+ json_node_unref (priv->current_node);
priv->current_node = old_current;
return G_TOKEN_RIGHT_BRACE;
@@ -769,8 +769,8 @@ json_parse_object (JsonParser *parser,
priv->error_code = JSON_PARSER_ERROR_MISSING_COMMA;
json_object_unref (object);
- json_node_free (member);
- json_node_free (priv->current_node);
+ json_node_unref (member);
+ json_node_unref (priv->current_node);
priv->current_node = old_current;
return G_TOKEN_COMMA;