From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33962) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zex7B-0004Ha-Mn for qemu-devel@nongnu.org; Wed, 23 Sep 2015 23:22:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zex78-0003qV-HI for qemu-devel@nongnu.org; Wed, 23 Sep 2015 23:22:33 -0400 Received: from mx1.redhat.com ([209.132.183.28]:32900) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zex78-0003qP-Az for qemu-devel@nongnu.org; Wed, 23 Sep 2015 23:22:30 -0400 Message-ID: <1443064948.23936.528.camel@redhat.com> From: Alex Williamson Date: Wed, 23 Sep 2015 21:22:28 -0600 In-Reply-To: <560365F6.1060000@cn.fujitsu.com> References: <20150923202200.6569.64538.stgit@gimli.home> <20150923202358.6569.29219.stgit@gimli.home> <560365F6.1060000@cn.fujitsu.com> Content-Type: text/plain; charset="UTF-8" Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PULL 10/19] vfio/pci: Foundation for new quirk structure List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Wen Congyang Cc: qemu-devel@nongnu.org On Thu, 2015-09-24 at 10:54 +0800, Wen Congyang wrote: > On 09/24/2015 04:23 AM, Alex Williamson wrote: > > @@ -275,12 +276,15 @@ static void vfio_vga_probe_ati_3c3_quirk(VFIOPCIDevice *vdev) > > } > > > > quirk = g_malloc0(sizeof(*quirk)); > > - quirk->vdev = vdev; > > + legacy = quirk->data = g_malloc0(sizeof(*legacy)); > > + quirk->mem = legacy->mem = g_malloc0_n(sizeof(MemoryRegion), 1); > > Why do you use g_malloc0_n() here? It is introduced in glib 2.24, but we only require glib 2.22. Because I saw it, I guess in scripts/coverity-model.c, and used it. In this particular instance it seems irrelevant, but VFIOQuirk.mem points to an array of MemoryRegions, other users here have more than one array entry and I chose to use the same allocator throughout for consistency. What's the preferred helper here, simply calloc()? Thanks, Alex