From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51161) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y8WJX-000686-Sh for qemu-devel@nongnu.org; Tue, 06 Jan 2015 10:45:00 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Y8WJT-0003ie-Ow for qemu-devel@nongnu.org; Tue, 06 Jan 2015 10:44:59 -0500 Received: from mx1.redhat.com ([209.132.183.28]:55404) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y8WJT-0003iW-HJ for qemu-devel@nongnu.org; Tue, 06 Jan 2015 10:44:55 -0500 Message-ID: <54AC02F4.40403@redhat.com> Date: Tue, 06 Jan 2015 08:44:52 -0700 From: Eric Blake MIME-Version: 1.0 References: <1419604968-87437-1-git-send-email-agraf@suse.de> <1419604968-87437-3-git-send-email-agraf@suse.de> In-Reply-To: <1419604968-87437-3-git-send-email-agraf@suse.de> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="339wLUq3d1oWG7slsxcmQ8wotWIgRuxS2" Subject: Re: [Qemu-devel] [PATCH v3 2/5] QJSON: Add JSON writer List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Alexander Graf , qemu-devel@nongnu.org Cc: amit.shah@redhat.com, pbonzini@redhat.com, afaerber@suse.de, quintela@redhat.com This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --339wLUq3d1oWG7slsxcmQ8wotWIgRuxS2 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 12/26/2014 07:42 AM, Alexander Graf wrote: > To support programmatic JSON assembly while keeping the code that gener= ates it > readable, this patch introduces a simple JSON writer. It emits JSON ser= ially > into a buffer in memory. >=20 > The nice thing about this writer is its simplicity and low memory overh= ead. > Unlike the QMP JSON writer, this one does not need to spawn QObjects fo= r every > element it wants to represent. >=20 > This is a prerequisite for the migration stream format description gene= rator. >=20 > Signed-off-by: Alexander Graf >=20 > --- >=20 > v2 -> v3: >=20 > - QOMify the QJSON object, makes for easier destruction > --- > include/qjson.h | 3 ++- > qjson.c | 39 ++++++++++++++++++++++++++++++++++++--- > 2 files changed, 38 insertions(+), 4 deletions(-) >=20 > diff --git a/include/qjson.h b/include/qjson.h > index 8f8c145..7c54fdf 100644 > --- a/include/qjson.h > +++ b/include/qjson.h > @@ -4,7 +4,7 @@ > * Copyright Alexander Graf > * > * Authors: > - * Alexander Graf + * Alexander Graf Umm, this should be squashed into 1/5. > @@ -85,9 +88,7 @@ const char *qjson_get_str(QJSON *json) > =20 > QJSON *qjson_new(void) > { > - QJSON *json =3D g_new(QJSON, 1); > - json->str =3D qstring_from_str("{ "); > - json->omit_comma =3D true; > + QJSON *json =3D (QJSON *)object_new(TYPE_QJSON); > return json; This undoes the dangling object that I complained about on patch 1; maybe there's some more squashing to do?... > +static void qjson_initfn(Object *obj) > +{ > + QJSON *json =3D (QJSON *)object_dynamic_cast(obj, TYPE_QJSON); > + assert(json); > + > + json->str =3D qstring_from_str("{ "); > + json->omit_comma =3D true; =2E..or is it still an incomplete object, just now in a different locatio= n? --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --339wLUq3d1oWG7slsxcmQ8wotWIgRuxS2 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJUrAL0AAoJEKeha0olJ0NqwKgH/3gMIrm2TVDyTZlhk7uIZnu+ ZeuJrOBT1yRXjLI1xUFV8V1rBI7QGUV6ikhSi+G7F91C+jphzpjBEmHNJ4kps1ew QnD2oiY5I/ZlEiwri+FIe8dNMLmXiF96f4rHiXp4PmWusZHN5mV1ubiU/o59QCiQ aqMIkUr0PbYLKmv1UA4p+JcGZ8+IZx8aGMo4Uf1Y4MtXxDJTP1eN+mFXwTD81Scu TEJfQFtfqneZQ5zRhC09A9TknR6HEwl3XpL0g3pry4/RldvpLdQcHmpjbFgtFDHL w4CWv/OJFvIjE4HlmA48j3SRujc4IbuGBDdhsRHfzVHBt4dtFlxgmjgyuea4K2A= =frZI -----END PGP SIGNATURE----- --339wLUq3d1oWG7slsxcmQ8wotWIgRuxS2--