From f6f8c3ba779e357801ebaefdf8ef8a426ab73ea4 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Mon, 7 Dec 2009 17:10:09 -0800 Subject: [PATCH] json: New convenience function json_array_create_1(). --- lib/json.c | 8 ++++++++ lib/json.h | 1 + 2 files changed, 9 insertions(+) diff --git a/lib/json.c b/lib/json.c index c31f418a..d162fd51 100644 --- a/lib/json.c +++ b/lib/json.c @@ -222,6 +222,14 @@ json_array_create(struct json **elements, size_t n) return json; } +struct json * +json_array_create_1(struct json *elem0) +{ + struct json **elems = xmalloc(sizeof *elems); + elems[0] = elem0; + return json_array_create(elems, 1); +} + struct json * json_array_create_2(struct json *elem0, struct json *elem1) { diff --git a/lib/json.h b/lib/json.h index 76740153..611dea50 100644 --- a/lib/json.h +++ b/lib/json.h @@ -76,6 +76,7 @@ struct json *json_array_create_empty(void); void json_array_add(struct json *, struct json *element); void json_array_trim(struct json *); struct json *json_array_create(struct json **, size_t n); +struct json *json_array_create_1(struct json *); struct json *json_array_create_2(struct json *, struct json *); struct json *json_array_create_3(struct json *, struct json *, struct json *); -- 2.30.2