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

Re: [Xen-devel] [PATCH 19/28] libxl: ocaml: add dominfo_list and dominfo_get


  • To: Ian Campbell <Ian.Campbell@xxxxxxxxxx>
  • From: Rob Hoes <Rob.Hoes@xxxxxxxxxx>
  • Date: Tue, 23 Apr 2013 14:18:05 +0100
  • Accept-language: en-US
  • Acceptlanguage: en-US
  • Cc: "xen-devel@xxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxx>
  • Delivery-date: Tue, 23 Apr 2013 13:18:52 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xen.org>
  • Thread-index: Ac42pwfBfviFB+p3R8WduGX3HF2HSAJfWYhA
  • Thread-topic: [PATCH 19/28] libxl: ocaml: add dominfo_list and dominfo_get

[...]
> > +   domlist = temp = Val_emptylist;
> > +   for (i = nb - 1; i >= 0; i--) {
> > +           domlist = caml_alloc_small(2, Tag_cons);
> > +           Field(domlist, 0) = Val_int(0);
> > +           Field(domlist, 1) = temp;
> > +           temp = domlist;
> > +
> > +           Store_field(domlist, 0, Val_dominfo(&c_domlist[i]));
> 
> Is the preceding "Field(domlist, 0) = Val_int(0);" storing to the same place
> and therefore redundant?

I think the main reason to do this here is that caml_alloc_small (a low-level 
function) does not initialise the fields (as Dave pointed out earlier), and it 
is necessary to initialise the fields before doing any subsequent allocation on 
the OCaml heap (e.g. in Val_dominfo). If you don't do that, the GC may try to 
evaluate the uninitialised value.

Cheers,
Rob
_______________________________________________
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®.