From mboxrd@z Thu Jan 1 00:00:00 1970 From: Wei Liu Subject: Re: new idl helper, append to Array Date: Thu, 4 Feb 2016 10:48:35 +0000 Message-ID: <20160204104835.GM23178@citrix.com> References: <20160204092353.GA17709@aepfle.de> <1454579894.25207.144.camel@citrix.com> <20160204100758.GA3492@aepfle.de> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Content-Disposition: inline In-Reply-To: <20160204100758.GA3492@aepfle.de> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Olaf Hering Cc: Wei Liu , Ian Campbell , xen-devel@lists.xen.org List-Id: xen-devel@lists.xenproject.org On Thu, Feb 04, 2016 at 11:07:58AM +0100, Olaf Hering wrote: > On Thu, Feb 04, Ian Campbell wrote: > > > I think the append_to variant is probably least gross. > > libxl_device_vscsidev_append_to_vscsictrl() would work too. > > This is what I will use for the time being (modulo introduced runtime bugs): > > void libxl_device_vscsictrl_append_vscsidev(libxl_ctx *ctx, > libxl_device_vscsictrl *ctrl, > libxl_device_vscsidev *dev) > { > GC_INIT(ctx); > ctrl->vscsidevs = libxl__realloc(NOGC, ctrl->vscsidevs, sizeof(*dev) * (ctrl->num_vscsidevs + 1)); > libxl_device_vscsidev_init(ctrl->vscsidevs + ctrl->num_vscsidevs); > libxl_device_vscsidev_copy(CTX, ctrl->vscsidevs + ctrl->num_vscsidevs, dev); > ctrl->num_vscsidevs++; > GC_FREE; > } > > > > Wei, is it necessary to init the dst before copy into it? > > It would clear the padding between members, a plain copy will leave them > uninitialized. > There is that. Yes, _init memset the whole structure to zeros. Wei. > Olaf