All of lore.kernel.org
 help / color / mirror / Atom feed
From: Michael Roth <mdroth@linux.vnet.ibm.com>
To: Luiz Capitulino <lcapitulino@redhat.com>
Cc: aliguori@us.ibm.com, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] json-parser: don't replicate tokens at each level of recursion
Date: Wed, 15 Aug 2012 12:50:06 -0500	[thread overview]
Message-ID: <20120815175006.GI16157@illuin> (raw)
In-Reply-To: <20120814022544.GE16157@illuin>

On Mon, Aug 13, 2012 at 09:25:44PM -0500, Michael Roth wrote:
> On Mon, Aug 13, 2012 at 03:01:56PM -0300, Luiz Capitulino wrote:
> > On Fri, 10 Aug 2012 18:24:10 -0500
> > Michael Roth <mdroth@linux.vnet.ibm.com> wrote:
> > 
> > > +    qlist_iter(tokens, tokens_count_from_iter, &count);
> > > +    if (count == 0) {
> > > +        return NULL;
> > > +    }
> > 
> > Please, add qlist_size() instead.
> > 
> 
> Gladly :) I spent a good amount for a function that did this, not sure
> how I missed it.
> 

Heh, read that as "please, use qlist_size() instead". I've added it
after further searching for it :)

> > > +
> > > +    ctxt = g_malloc0(sizeof(JSONParserContext));
> > > +    ctxt->tokens.pos = 0;
> > > +    ctxt->tokens.count = count;
> > > +    ctxt->tokens.buf = g_malloc(count * sizeof(QObject *));
> > > +    qlist_iter(tokens, tokens_append_from_iter, ctxt);
> > > +    ctxt->tokens.pos = 0;
> > > +
> > > +    return ctxt;
> > > +}
> > > +
> > > +static void parser_context_free(JSONParserContext *ctxt)
> > > +{
> > > +    int i;
> > > +    if (ctxt) {
> > > +        for (i = 0; i < ctxt->tokens.count; i++) {
> > > +            qobject_decref(ctxt->tokens.buf[i]);
> > > +        }
> > > +        g_free(ctxt->tokens.buf);
> > > +        g_free(ctxt);
> > 
> > Isn't this leaking ctxt->err?
> > 
> 
> Indeed. Looks like we were leaking this previously as well. I'll get it
> in V2.
> 

Apparently not, actually. It looks like error_propagate() handles
whether to free the error or pass it up the stack, so we can't mess with
it in the free function. I've added a comment to note that ctxt->err
needs to be freed seperately.

V2 is incoming with comments addressed.

  reply	other threads:[~2012-08-15 17:50 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-10 23:24 [Qemu-devel] [PATCH] json-parser: don't replicate tokens at each level of recursion Michael Roth
2012-08-13 18:01 ` Luiz Capitulino
2012-08-14  2:25   ` Michael Roth
2012-08-15 17:50     ` Michael Roth [this message]
2012-08-13 18:49 ` Markus Armbruster
2012-08-14  2:30   ` Michael Roth

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=20120815175006.GI16157@illuin \
    --to=mdroth@linux.vnet.ibm.com \
    --cc=aliguori@us.ibm.com \
    --cc=lcapitulino@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /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.