From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45042) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XKDKi-0000js-Oq for qemu-devel@nongnu.org; Wed, 20 Aug 2014 17:22:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XKDKc-0004Ok-Cs for qemu-devel@nongnu.org; Wed, 20 Aug 2014 17:22:16 -0400 Received: from mx1.redhat.com ([209.132.183.28]:41200) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XKDKc-0004Oe-62 for qemu-devel@nongnu.org; Wed, 20 Aug 2014 17:22:10 -0400 Date: Wed, 20 Aug 2014 23:22:29 +0200 From: "Michael S. Tsirkin" Message-ID: <20140820212229.GA26229@redhat.com> References: <1408559891-11313-1-git-send-email-armbru@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1408559891-11313-1-git-send-email-armbru@redhat.com> Subject: Re: [Qemu-devel] [PATCH 1/1] loader: g_realloc(p, 0) frees and returns NULL, simplify List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Markus Armbruster Cc: qemu-devel@nongnu.org, aurelien@aurel32.net On Wed, Aug 20, 2014 at 08:38:11PM +0200, Markus Armbruster wrote: > Once upon a time, it was decided that qemu_realloc(ptr, 0) should > abort. Switching to glib retired that bright idea. A bit of code > that was added to cope with it (commit 3e372cf) is still around. Bury > it. > > See also commit 6528499. > > Signed-off-by: Markus Armbruster Acked-by: Michael S. Tsirkin > --- > include/hw/elf_ops.h | 15 +++++---------- > 1 file changed, 5 insertions(+), 10 deletions(-) > > diff --git a/include/hw/elf_ops.h b/include/hw/elf_ops.h > index c6b5129..a517753 100644 > --- a/include/hw/elf_ops.h > +++ b/include/hw/elf_ops.h > @@ -147,18 +147,13 @@ static int glue(load_symbols, SZ)(struct elfhdr *ehdr, int fd, int must_swab, > } > i++; > } > - if (nsyms) { > - syms = g_realloc(syms, nsyms * sizeof(*syms)); > + syms = g_realloc(syms, nsyms * sizeof(*syms)); > > - qsort(syms, nsyms, sizeof(*syms), glue(symcmp, SZ)); > - for (i = 0; i < nsyms - 1; i++) { > - if (syms[i].st_size == 0) { > - syms[i].st_size = syms[i + 1].st_value - syms[i].st_value; > - } > + qsort(syms, nsyms, sizeof(*syms), glue(symcmp, SZ)); > + for (i = 0; i < nsyms - 1; i++) { > + if (syms[i].st_size == 0) { > + syms[i].st_size = syms[i + 1].st_value - syms[i].st_value; > } > - } else { > - g_free(syms); > - syms = NULL; > } > > /* String table */ > -- > 1.9.3