From: Ian Jackson Subject: Re: [PATCH V2 1/2] libxl: Have flexarray using the GC Date: Thu, 4 Oct 2012 18:31:21 +0100 Message-ID: <20589.51177.530142.664975@mariner.uk.xensource.com> References: <1349367522-16695-1-git-send-email-anthony.perard@citrix.com> <1349367522-16695-2-git-send-email-anthony.perard@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1349367522-16695-2-git-send-email-anthony.perard@citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Anthony PERARD Cc: Ian Campbell , Xen Devel List-Id: xen-devel@lists.xenproject.org Anthony PERARD writes ("[PATCH V2 1/2] libxl: Have flexarray using the GC"): > This patch makes the flexarray function libxl__gc aware. > +/* > + * It is safe to store gc in the struct because: > + * - If it an actual gc, then the flexarray should not be used after the gc > + * have been freed. > + * - If it is a NOGC, then this point to a structure embedded in libxl_ctx, > + * therefore will survive across several libxl calls. > + */ Thanks, I think this explanation is correct. > +static int gc_is_real(const libxl__gc *gc) > +{ > + return gc->alloc_maxsize >= 0; > +} You have cloned-and-hacked this from libxl_internal.c ! Instead, either declare it in libxl_internal.h, or move it there and make it "static inline". > @@ -104,7 +115,8 @@ void **flexarray_contents(flexarray_t *array) > { > void **data; > data = array->data; > - free(array); > + if (!gc_is_real(array->gc)) > + free(array); > return data; What an odd function. However, your patch to it seems right to me. > diff --git a/tools/libxl/flexarray.h b/tools/libxl/flexarray.h > index ae17f3b..aade417 100644 And the rest of the patch is mostly an impressive number of deletions. I won't check the semantics of each one but the style seems plausible. Thanks! Ian.