Merge tag 'v9.0.0-rc3'
[qemu/ar7.git] / qapi / qapi-type-helpers.c
blob266da013ad6464b29e123fb7e3df50e2be7092f0
1 /*
2 * QAPI common helper functions
4 * This file provides helper functions related to types defined
5 * in the QAPI schema.
7 * This work is licensed under the terms of the GNU LGPL, version 2.1 or later.
8 * See the COPYING.LIB file in the top-level directory.
12 #include "qemu/osdep.h"
13 #include "qapi/error.h"
14 #include "qapi/type-helpers.h"
16 HumanReadableText *human_readable_text_from_str(GString *str)
18 HumanReadableText *ret = g_new0(HumanReadableText, 1);
20 ret->human_readable_text = g_steal_pointer(&str->str);
22 return ret;
25 char **strv_from_str_list(const strList *list)
27 const strList *tail;
28 int i = 0;
29 char **strv = g_new(char *, QAPI_LIST_LENGTH(list) + 1);
31 for (tail = list; tail != NULL; tail = tail->next) {
32 strv[i++] = g_strdup(tail->value);
34 strv[i] = NULL;
36 return strv;