summaryrefslogtreecommitdiffstats
path: root/qobject
diff options
context:
space:
mode:
authorAlberto Garcia2018-06-29 13:36:59 +0200
committerKevin Wolf2018-08-15 12:50:39 +0200
commit655b4b67e380891ee3996349213c62088d71395d (patch)
treef7298de932b9bc13ea0109f44688735799f0eeee /qobject
parentblock: drop empty .bdrv_close handlers (diff)
downloadqemu-655b4b67e380891ee3996349213c62088d71395d.tar.gz
qemu-655b4b67e380891ee3996349213c62088d71395d.tar.xz
qemu-655b4b67e380891ee3996349213c62088d71395d.zip
qdict: Make qdict_extract_subqdict() accept dst = NULL
This function extracts all options from a QDict starting with a certain prefix and puts them in a new QDict. We'll have a couple of cases where we simply want to discard those options instead of copying them, and that's what this patch does. Signed-off-by: Alberto Garcia <berto@igalia.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'qobject')
-rw-r--r--qobject/block-qdict.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/qobject/block-qdict.c b/qobject/block-qdict.c
index 80c653013f..42054cc274 100644
--- a/qobject/block-qdict.c
+++ b/qobject/block-qdict.c
@@ -158,20 +158,25 @@ void qdict_flatten(QDict *qdict)
qdict_flatten_qdict(qdict, qdict, NULL);
}
-/* extract all the src QDict entries starting by start into dst */
+/* extract all the src QDict entries starting by start into dst.
+ * If dst is NULL then the entries are simply removed from src. */
void qdict_extract_subqdict(QDict *src, QDict **dst, const char *start)
{
const QDictEntry *entry, *next;
const char *p;
- *dst = qdict_new();
+ if (dst) {
+ *dst = qdict_new();
+ }
entry = qdict_first(src);
while (entry != NULL) {
next = qdict_next(src, entry);
if (strstart(entry->key, start, &p)) {
- qdict_put_obj(*dst, p, qobject_ref(entry->value));
+ if (dst) {
+ qdict_put_obj(*dst, p, qobject_ref(entry->value));
+ }
qdict_del(src, entry->key);
}
entry = next;