summaryrefslogtreecommitdiff
path: root/json-glib/json-node.c
diff options
context:
space:
mode:
authorEmmanuele Bassi <ebassi@openedhand.com>2007-12-25 11:47:10 +0000
committerEmmanuele Bassi <ebassi@openedhand.com>2007-12-25 11:47:10 +0000
commit7229b9bf0bd15c6c1e5b695f8e291218a041ab45 (patch)
tree528609747c9a8500186fb166b171978a911262f3 /json-glib/json-node.c
parentba7282dd23e2980203208cb73942535bfefa5906 (diff)
downloadjson-glib-7229b9bf0bd15c6c1e5b695f8e291218a041ab45.tar.gz
Initialise to zero when creating/copying a JsonNode
Avoid feeding garbage to the callers by using g_slice_new0().
Diffstat (limited to 'json-glib/json-node.c')
-rw-r--r--json-glib/json-node.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/json-glib/json-node.c b/json-glib/json-node.c
index 04e2092..faf1943 100644
--- a/json-glib/json-node.c
+++ b/json-glib/json-node.c
@@ -48,7 +48,7 @@ json_node_get_type (void)
static GType node_type = 0;
if (G_UNLIKELY (node_type == 0))
- node_type = g_boxed_type_register_static ("JsonNode",
+ node_type = g_boxed_type_register_static (g_intern_static_string ("JsonNode"),
(GBoxedCopyFunc) json_node_copy,
(GBoxedFreeFunc) json_node_free);
@@ -103,9 +103,10 @@ json_node_new (JsonNodeType type)
{
JsonNode *data;
- g_return_val_if_fail (type >= JSON_NODE_OBJECT && type <= JSON_NODE_NULL, NULL);
+ g_return_val_if_fail (type >= JSON_NODE_OBJECT &&
+ type <= JSON_NODE_NULL, NULL);
- data = g_slice_new (JsonNode);
+ data = g_slice_new0 (JsonNode);
data->type = type;
return data;
@@ -127,7 +128,7 @@ json_node_copy (JsonNode *node)
g_return_val_if_fail (node != NULL, NULL);
- copy = g_slice_new (JsonNode);
+ copy = g_slice_new0 (JsonNode);
*copy = *node;
switch (copy->type)