[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH RFC V2 05/10] libxl_json: introduce parser functions for builtin types



On Wed, Apr 23, 2014 at 11:01:34AM +0100, Wei Liu wrote:
> On Tue, Apr 22, 2014 at 04:09:58PM +0100, Ian Campbell wrote:
> > Please could you CC Anthony too, I think he wrote all this
> > libxl__json_object stuff.
> > 
> > On Thu, 2014-04-17 at 12:13 +0100, Wei Liu wrote:
> > > @@ -396,6 +396,66 @@ out:
> > >      return s;
> > >  }
> > >  
> > > +int libxl_cpuid_policy_list_parse_json(libxl_ctx *ctx,
> > > +                                       const libxl__json_object *o,
> > > +                                       libxl_cpuid_policy_list *p)
> > > +{
> > > +    int i, size;
> > > +    libxl_cpuid_policy_list l;
> > > +
> > > +    if (!libxl__json_object_is_array(o))
> > > +        return -1;
> > > +
> > > +    if (!o->u.array->count)
> > > +        return 0;
> > > +
> > > +    size = o->u.array->count;
> > > +    /* need one extra slot as setinel */
> > 
> > "sentinel"
> > 
> > > +    l = *p = calloc(size + 1, sizeof(libxl_cpuid_policy));
> > 
> > This function should GC_INIT and use the provided gc for allocations,
> > shouldn't it?.
> > 
> 
> I see. You're right here.

I was wrong about this.

This (and other allocations alike) should use calloc instead of GC
allocation. We don't want GC to free the memory until dispose is called.

If you look at libxl_string_list_dispose you will see the allocation of
the list itself is freed at the end of the function.

libxl_cpuid_list forget to do that. It should be fixed.

Wei.

> 

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.