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

Re: [Xen-devel] [OPW PATCH V2] tools/xl: Call init function for libxl defined datatypes



Uma Sharma writes ("[OPW PATCH V2] tools/xl: Call init function for libxl 
defined datatypes"):
> This patch calls init function for libxl_domain_sched_params before
> passing it as reference to sched_domain_get() function in
> tools/libxl/xl_cmdimpl.c
> IDL generated libxl types should be used only after calling the init
> function even if the variable is simply being passed by reference as
> an output parameter to a libxl function
...
>      } else if (optind == argc-1) {
>          uint32_t domid = find_domain(argv[optind]);
> +     libxl_dominfo_init(&info_buf);
>          rc = libxl_domain_info(ctx, &info_buf, domid);
>          if (rc == ERROR_INVAL) {
>              fprintf(stderr, "Error: Domain \'%s\' does not exist.\n",
> @@ -4366,6 +4367,7 @@ int main_list(int argc, char **argv)
>          }
>          info = &info_buf;
>          nb_domain = 1;
> +     libxl_dominfo_dispose(&info_buf);
>      } else {

I'm not a huge fan of this ad-hoc at-the-call-site memory management.
In libxl we generally try to initialise things where they are
declared, and free them on all exit paths from the function.

So while this patch is OK, and I'm not nacking it, I'd like to suggest
that future patches ought to use the other allocation-handling style.

For an example, see (for example) the handling of `tinfo' in
libxl_nodemap_to_cpumap in libxl_utils.c.

Ian.

_______________________________________________
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®.