[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH V8 16/39] qapi: strv_from_strList
From: |
Steve Sistare |
Subject: |
[PATCH V8 16/39] qapi: strv_from_strList |
Date: |
Wed, 15 Jun 2022 07:52:03 -0700 |
Signed-off-by: Steve Sistare <steven.sistare@oracle.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..8c96cab 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_malloc((QAPI_LIST_LENGTH(args) + 1) * sizeof(char *));
+
+ 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 V8 27/39] vfio-pci: cpr part 1 (fd and dma), (continued)
- [PATCH V8 27/39] vfio-pci: cpr part 1 (fd and dma), Steve Sistare, 2022/06/15
- [PATCH V8 34/39] chardev: cpr for simple devices, Steve Sistare, 2022/06/15
- [PATCH V8 39/39] tests/avocado: add cpr regression test, Steve Sistare, 2022/06/15
- [PATCH V8 30/39] vfio-pci: recover from unmap-all-vaddr failure, Steve Sistare, 2022/06/15
- [PATCH V8 38/39] python/machine: add QEMUMachine accessors, Steve Sistare, 2022/06/15
- [PATCH V8 01/39] migration: fix populate_vfio_info, Steve Sistare, 2022/06/15
- [PATCH V8 05/39] vl: start on wakeup request, Steve Sistare, 2022/06/15
- [PATCH V8 07/39] cpr: reboot HMP interfaces, Steve Sistare, 2022/06/15
- [PATCH V8 16/39] qapi: strv_from_strList,
Steve Sistare <=
- [PATCH V8 15/39] qapi: QAPI_LIST_LENGTH, Steve Sistare, 2022/06/15
- [PATCH V8 04/39] memory: RAM_ANON flag, Steve Sistare, 2022/06/15