All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: "Daniel P. Berrange" <berrange@redhat.com>
Cc: qemu-devel <qemu-devel@nongnu.org>, Jun Koi <junkoi2004@gmail.com>
Subject: Re: [Qemu-devel] [patch] replace all strdup() with g_strdup()
Date: Fri, 16 Dec 2011 11:21:47 +0100	[thread overview]
Message-ID: <4EEB1BBB.4030003@redhat.com> (raw)
In-Reply-To: <20111216094117.GB9860@redhat.com>

On 12/16/2011 10:41 AM, Daniel P. Berrange wrote:
> Yes&  no. In general you are correct that g_malloc/g_strdup needs to
> be matched with g_free, but in the context of the QEMU binary at least
> we don't strictly need that.
>
> The general issue is that GLib's memory allocators default to the
> system malloc/free, but with    g_mem_set_vtable   it is possible
> to override those allocators.
>
> So any libraries using GLib should definitely take care to match
> g_malloc/g_strdup/g_free, but if you are a self contained program
> that never calls g_mem_set_vtable, we don't technically have to
> worry about it.

I think the keyword here is "technically". :)  If we want to use the 
GLib profiling allocators or any other kind of statistic gathering, we 
do have to match the allocations.  Right now, we're not getting it 100% 
right, but sweeping conversions make it harder to just grep-w for 
malloc/free/strdup.

Paolo

  reply	other threads:[~2011-12-16 10:22 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-16  8:07 [Qemu-devel] [patch] replace all strdup() with g_strdup() Jun Koi
2011-12-16  8:44 ` 陳韋任
2011-12-16  9:26 ` Paolo Bonzini
2011-12-16  9:41   ` Daniel P. Berrange
2011-12-16 10:21     ` Paolo Bonzini [this message]
2011-12-16  9:26 ` Peter Maydell

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=4EEB1BBB.4030003@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=berrange@redhat.com \
    --cc=junkoi2004@gmail.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.