All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: Alexander Graf <agraf@suse.de>, qemu-devel@nongnu.org
Cc: amit.shah@redhat.com, pbonzini@redhat.com, afaerber@suse.de,
	quintela@redhat.com
Subject: Re: [Qemu-devel] [PATCH v3 1/5] QJSON: Add JSON writer
Date: Tue, 06 Jan 2015 08:41:49 -0700	[thread overview]
Message-ID: <54AC023D.80501@redhat.com> (raw)
In-Reply-To: <1419604968-87437-2-git-send-email-agraf@suse.de>

[-- Attachment #1: Type: text/plain, Size: 1506 bytes --]

On 12/26/2014 07:42 AM, Alexander Graf wrote:
> To support programmatic JSON assembly while keeping the code that generates it
> readable, this patch introduces a simple JSON writer. It emits JSON serially
> into a buffer in memory.
> 
> The nice thing about this writer is its simplicity and low memory overhead.
> Unlike the QMP JSON writer, this one does not need to spawn QObjects for every
> element it wants to represent.
> 
> This is a prerequisite for the migration stream format description generator.
> 
> Signed-off-by: Alexander Graf <agraf@suse.de>
> ---
>  Makefile.objs   |  1 +
>  include/qjson.h | 28 +++++++++++++++++
>  qjson.c         | 97 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>  3 files changed, 126 insertions(+)
>  create mode 100644 include/qjson.h
>  create mode 100644 qjson.c

> +struct QJSON {
> +    QString *str;
> +    bool omit_comma;
> +    unsigned long self_size_offset;

Would size_t be smarter for this field?

> +}
> +
> +const char *qjson_get_str(QJSON *json)
> +{
> +    return qstring_get_str(json->str);
> +}
> +
> +QJSON *qjson_new(void)
> +{
> +    QJSON *json = g_new(QJSON, 1);
> +    json->str = qstring_from_str("{ ");
> +    json->omit_comma = true;
> +    return json;

If I'm not mistaken, this creates an open-ended object, as in "{ ...".
Should qjson_get_str add the closing }?

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]

  reply	other threads:[~2015-01-06 15:42 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-26 14:42 [Qemu-devel] [PATCH v3 0/5] Migration Deciphering aid Alexander Graf
2014-12-26 14:42 ` [Qemu-devel] [PATCH v3 1/5] QJSON: Add JSON writer Alexander Graf
2015-01-06 15:41   ` Eric Blake [this message]
2015-01-06 21:39     ` Alexander Graf
2014-12-26 14:42 ` [Qemu-devel] [PATCH v3 2/5] " Alexander Graf
2015-01-06 15:44   ` Eric Blake
2015-01-06 21:16     ` Alexander Graf
2014-12-26 14:42 ` [Qemu-devel] [PATCH v3 3/5] qemu-file: Add fast ftell code path Alexander Graf
2015-01-06 15:46   ` Eric Blake
2014-12-26 14:42 ` [Qemu-devel] [PATCH v3 4/5] migration: Append JSON description of migration stream Alexander Graf
2015-01-06 15:56   ` Eric Blake
2015-01-06 21:25     ` Alexander Graf
2015-01-20 10:30   ` Amit Shah
2014-12-26 14:42 ` [Qemu-devel] [PATCH v3 5/5] Add migration stream analyzation script Alexander Graf
2015-01-06 16:05   ` Eric Blake
2015-01-06 21:29     ` Alexander Graf
2015-01-20 10:31 ` [Qemu-devel] [PATCH v3 0/5] Migration Deciphering aid Amit Shah
2015-01-20 10:54   ` Alexander Graf
2015-01-21  6:05     ` Amit Shah

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=54AC023D.80501@redhat.com \
    --to=eblake@redhat.com \
    --cc=afaerber@suse.de \
    --cc=agraf@suse.de \
    --cc=amit.shah@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=quintela@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.