diff options
author | BenoƮt Canet <benoit@irqsave.net> | 2013-09-25 13:30:01 +0200 |
---|---|---|
committer | Kevin Wolf <kwolf@redhat.com> | 2013-09-25 16:21:28 +0200 |
commit | 5726d872f3c7a78a6c17ff5a6e47e01cff0a5e55 (patch) | |
tree | 63261e5b688f1f83ff1709e4765ee50c7fddad58 /qobject | |
parent | c3e4f43a99549daa6e9b87350922e8339341c2ab (diff) | |
download | qemu-5726d872f3c7a78a6c17ff5a6e47e01cff0a5e55.zip qemu-5726d872f3c7a78a6c17ff5a6e47e01cff0a5e55.tar.gz qemu-5726d872f3c7a78a6c17ff5a6e47e01cff0a5e55.tar.bz2 |
qdict: Extract qdict_extract_subqdict
Signed-off-by: Benoit Canet <benoit@irqsave.net>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'qobject')
-rw-r--r-- | qobject/qdict.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/qobject/qdict.c b/qobject/qdict.c index 472f106..0f3e0a6 100644 --- a/qobject/qdict.c +++ b/qobject/qdict.c @@ -527,3 +527,24 @@ void qdict_flatten(QDict *qdict) { qdict_do_flatten(qdict, qdict, NULL); } + +/* extract all the src QDict entries starting by start into dst */ +void qdict_extract_subqdict(QDict *src, QDict **dst, const char *start) + +{ + const QDictEntry *entry, *next; + const char *p; + + *dst = qdict_new(); + entry = qdict_first(src); + + while (entry != NULL) { + next = qdict_next(src, entry); + if (strstart(entry->key, start, &p)) { + qobject_incref(entry->value); + qdict_put_obj(*dst, p, entry->value); + qdict_del(src, entry->key); + } + entry = next; + } +} |