[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH V9 13/46] qapi: strv_from_strList
From: |
Steve Sistare |
Subject: |
[PATCH V9 13/46] qapi: strv_from_strList |
Date: |
Tue, 26 Jul 2022 09:10:10 -0700 |
Signed-off-by: Steve Sistare <steven.sistare@oracle.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
include/qapi/util.h | 6 ++++++
qapi/qapi-util.c | 14 ++++++++++++++
2 files changed, 20 insertions(+)
diff --git a/include/qapi/util.h b/include/qapi/util.h
index 75dddca..51ff64e 100644
--- a/include/qapi/util.h
+++ b/include/qapi/util.h
@@ -33,6 +33,12 @@ bool qapi_bool_parse(const char *name, const char *value,
bool *obj,
int parse_qapi_name(const char *name, bool complete);
/*
+ * Produce and return a NULL-terminated array of strings from @args.
+ * All strings are g_strdup'd.
+ */
+GStrv strv_from_strList(const struct strList *args);
+
+/*
* Produce a strList from the character delimited string @in.
* All strings are g_strdup'd.
* A NULL or empty input string returns NULL.
diff --git a/qapi/qapi-util.c b/qapi/qapi-util.c
index b61c73c..fe6bda2 100644
--- a/qapi/qapi-util.c
+++ b/qapi/qapi-util.c
@@ -154,6 +154,20 @@ int parse_qapi_name(const char *str, bool complete)
return p - str;
}
+GStrv strv_from_strList(const strList *args)
+{
+ const strList *arg;
+ int i = 0;
+ GStrv argv = g_new(char *, QAPI_LIST_LENGTH(args) + 1);
+
+ for (arg = args; arg != NULL; arg = arg->next) {
+ argv[i++] = g_strdup(arg->value);
+ }
+ argv[i] = NULL;
+
+ return argv;
+}
+
strList *strList_from_string(const char *in, char delim)
{
strList *res = NULL;
--
1.8.3.1
- [PATCH V9 00/46] Live Update, Steve Sistare, 2022/07/26
- [PATCH V9 12/46] qapi: QAPI_LIST_LENGTH, Steve Sistare, 2022/07/26
- [PATCH V9 03/46] migration: file URI, Steve Sistare, 2022/07/26
- [PATCH V9 02/46] memory: RAM_NAMED_FILE flag, Steve Sistare, 2022/07/26
- [PATCH V9 01/46] migration: fix populate_vfio_info, Steve Sistare, 2022/07/26
- [PATCH V9 14/46] qapi: strList unit tests, Steve Sistare, 2022/07/26
- [PATCH V9 13/46] qapi: strv_from_strList,
Steve Sistare <=
- [PATCH V9 18/46] memory: flat section iterator, Steve Sistare, 2022/07/26
- [PATCH V9 04/46] migration: mode parameter, Steve Sistare, 2022/07/26
- [PATCH V9 21/46] cpr: preserve extra state, Steve Sistare, 2022/07/26
- [PATCH V9 19/46] oslib: qemu_clear_cloexec, Steve Sistare, 2022/07/26
- [PATCH V9 30/46] vfio-pci: refactor for cpr, Steve Sistare, 2022/07/26
- [PATCH V9 27/46] hostmem-memfd: cpr support, Steve Sistare, 2022/07/26
- [PATCH V9 25/46] cpr: only-cpr-capable, Steve Sistare, 2022/07/26
- [PATCH V9 20/46] vl: helper to request re-exec, Steve Sistare, 2022/07/26
- [PATCH V9 05/46] migration: migrate-enable-mode option, Steve Sistare, 2022/07/26
- [PATCH V9 24/46] cpr: ram block blockers, Steve Sistare, 2022/07/26