return -1;
}
+/*
+ * NOGC can be used with those json_object functions, but the
+ * libxl__json_object* will need to be freed with libxl__json_object_free.
+ */
+_hidden libxl__json_object *libxl__json_object_alloc(libxl__gc *gc_opt,
+ libxl__json_node_type type);
+_hidden int libxl__json_object_append_to(libxl__gc *gc_opt,
+ libxl__json_object *obj,
+ libxl__json_object *dst);
_hidden libxl__json_object *libxl__json_array_get(const libxl__json_object *o,
int i);
_hidden
_hidden const libxl__json_object *libxl__json_map_get(const char *key,
const libxl__json_object *o,
libxl__json_node_type expected_type);
-_hidden void libxl__json_object_free(libxl__gc *gc, libxl__json_object *obj);
+_hidden void libxl__json_object_free(libxl__gc *gc_opt,
+ libxl__json_object *obj);
-_hidden libxl__json_object *libxl__json_parse(libxl__gc *gc, const char *s);
+_hidden libxl__json_object *libxl__json_parse(libxl__gc *gc_opt, const char *s);
/* Based on /local/domain/$domid/dm-version xenstore key
* default is qemu xen traditional */
* libxl__json_object helper functions
*/
-static libxl__json_object *json_object_alloc(libxl__gc *gc,
+libxl__json_object *libxl__json_object_alloc(libxl__gc *gc,
libxl__json_node_type type)
{
libxl__json_object *obj;
return obj;
}
-static int json_object_append_to(libxl__gc *gc,
+int libxl__json_object_append_to(libxl__gc *gc,
libxl__json_object *obj,
libxl__json_object *dst)
{
DEBUG_GEN(ctx, null);
- obj = json_object_alloc(ctx->gc, JSON_NULL);
+ obj = libxl__json_object_alloc(ctx->gc, JSON_NULL);
- if (json_object_append_to(ctx->gc, obj, ctx->current) == -1) {
+ if (libxl__json_object_append_to(ctx->gc, obj, ctx->current) == -1) {
return 0;
}
DEBUG_GEN_VALUE(ctx, bool, boolean);
- obj = json_object_alloc(ctx->gc,
- boolean ? JSON_TRUE : JSON_FALSE);
+ obj = libxl__json_object_alloc(ctx->gc,
+ boolean ? JSON_TRUE : JSON_FALSE);
- if (json_object_append_to(ctx->gc, obj, ctx->current) == -1) {
+ if (libxl__json_object_append_to(ctx->gc, obj, ctx->current) == -1) {
return 0;
}
goto error;
}
- obj = json_object_alloc(ctx->gc, JSON_DOUBLE);
+ obj = libxl__json_object_alloc(ctx->gc, JSON_DOUBLE);
obj->u.d = d;
} else {
long long i = strtoll(s, NULL, 10);
goto error;
}
- obj = json_object_alloc(ctx->gc, JSON_INTEGER);
+ obj = libxl__json_object_alloc(ctx->gc, JSON_INTEGER);
obj->u.i = i;
}
goto out;
error:
/* If the conversion fail, we just store the original string. */
- obj = json_object_alloc(ctx->gc, JSON_NUMBER);
+ obj = libxl__json_object_alloc(ctx->gc, JSON_NUMBER);
t = libxl__zalloc(ctx->gc, len + 1);
strncpy(t, s, len);
obj->u.string = t;
out:
- if (json_object_append_to(ctx->gc, obj, ctx->current) == -1) {
+ if (libxl__json_object_append_to(ctx->gc, obj, ctx->current) == -1) {
return 0;
}
strncpy(t, (const char *) str, len);
t[len] = 0;
- obj = json_object_alloc(ctx->gc, JSON_STRING);
+ obj = libxl__json_object_alloc(ctx->gc, JSON_STRING);
obj->u.string = t;
- if (json_object_append_to(ctx->gc, obj, ctx->current) == -1) {
+ if (libxl__json_object_append_to(ctx->gc, obj, ctx->current) == -1) {
return 0;
}
DEBUG_GEN(ctx, map_open);
- obj = json_object_alloc(ctx->gc, JSON_MAP);
+ obj = libxl__json_object_alloc(ctx->gc, JSON_MAP);
if (ctx->current) {
- if (json_object_append_to(ctx->gc, obj, ctx->current) == -1) {
+ if (libxl__json_object_append_to(ctx->gc, obj, ctx->current) == -1) {
return 0;
}
}
DEBUG_GEN(ctx, array_open);
- obj = json_object_alloc(ctx->gc, JSON_ARRAY);
+ obj = libxl__json_object_alloc(ctx->gc, JSON_ARRAY);
if (ctx->current) {
- if (json_object_append_to(ctx->gc, obj, ctx->current) == -1) {
+ if (libxl__json_object_append_to(ctx->gc, obj, ctx->current) == -1) {
return 0;
}
}