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

Re: [Xen-devel] [PATCH 01 of 23] libxl: Document _init/_dispose/_setdefault functions



Ian Campbell writes ("[Xen-devel] [PATCH 01 of 23] libxl: Document 
_init/_dispose/_setdefault functions"):
> + * void libxl_<type>_init_<subfield>(<type> *p, subfield):
> + *
> + *    Initialise those parts of "p" which are not initialised by the
> + *    main init function due to the unknown value of "subfield". Sets
> + *    p->subfield as well as initialising any fields to their default
> + *    values.
> + *
> + *    p->subfield must not have been previously initialised.
> + *
> + *    This method is provided for any aggregate type which is used as
> + *    an input parameter.

This final sentence needs a qualification I think.

> + * void libxl_<type>_dispose(instance *p):
> + *
> + *    Frees any dynamically allocated memory used by the members of
> + *    "p" but not the storage used by "p" itself (this allows for the
> + *    allocation of arrays of types and for the composition of types).
> + *
> + *    In general this method is only provided for types where memory
> + *    can be dynamically allocated as part of that type.

Is whether dynamic allocation may happen a very stable part of the
libxl API ?  If we add a dynamically allocated member to one of these
structs, don't we inevitably introduce a memory leak into all
callers ?

I think it would be better to provide a dispose function corresponding
to every init function.

Ian.

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


 


Rackspace

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