[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v6 03/22] qdict: Add qdict_array_split()
From: |
Eric Blake |
Subject: |
Re: [Qemu-devel] [PATCH v6 03/22] qdict: Add qdict_array_split() |
Date: |
Thu, 19 Dec 2013 14:20:37 -0700 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.2.0 |
On 12/19/2013 12:47 PM, Max Reitz wrote:
> This function splits a QDict consisting of entries prefixed by
> incrementally enumerated indices into a QList of QDicts.
>
> Signed-off-by: Max Reitz <address@hidden>
> Reviewed-by: Kevin Wolf <address@hidden>
> ---
> include/qapi/qmp/qdict.h | 1 +
> qobject/qdict.c | 36 ++++++++++++++++++++++++++++++++++++
> 2 files changed, 37 insertions(+)
> +
> +/**
> + * qdict_array_split(): This function creates a QList of QDicts. Every entry
> in
> + * the original QDict with a key prefixed "%u.", where %u designates an
> unsigned
> + * integer starting at 0 and incrementally counting up, will be moved to a
> new
> + * QDict at index %u in the output QList with the key prefix removed. The
> + * function terminates when there is no entry in the QDict with a prefix
> + * directly (incrementally) following the last one.
> + * Example: {"0.a": 42, "0.b": 23, "1.x": 0, "3.y": 1, "o.o": 7}
> + * (or {"1.x": 0, "3.y": 1, "0.a": 42, "o.o": 7, "0.b": 23})
> + * => [{"a": 42, "b": 23}, {"x": 0}]
> + * and {"3.y": 1, "o.o": 7} (remainder of the old QDict)
It took me a read through the function to realize the "and ...
(remainder)" comment refers to the input QDict, which is modified
in-place as a side effect. Maybe change the first sentence to:
This function moves array-like elements of a QDict into a new QList of
QDicts.
But that's minor, and doesn't stop me from adding:
Reviewed-by: Eric Blake <address@hidden>
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature