From: Ben Pfaff Date: Tue, 8 Dec 2009 01:10:09 +0000 (-0800) Subject: json: New convenience function json_array_create_1(). X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f6f8c3ba779e357801ebaefdf8ef8a426ab73ea4;p=openvswitch json: New convenience function json_array_create_1(). --- 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 *);