[Libvir] 1/4 Additions to the public API

Daniel Veillard veillard at redhat.com
Thu Feb 21 22:13:51 UTC 2008


On Thu, Feb 21, 2008 at 08:56:17PM +0000, Richard W.M. Jones wrote:
> This just adds the four new functions to the public API.
[...]
> +/**
> + * virNetworkDHCPHostMapping:
> + *
> + * hostname mappings are returned by virNetworkListDHCPHostMapping.
> + */
> +typedef struct _virNetworkDHCPHostMapping {
> +  char *hwaddr;
> +  char *ipaddr;
> +  char *hostname;
> +} virNetworkDHCPHostMapping;
> +
> +typedef virNetworkDHCPHostMapping *virNetworkDHCPHostMappingPtr;
> +
[...]
> +int                     virNetworkListDHCPHostMappings
> +                                                (virNetworkPtr network,
> +				  virNetworkDHCPHostMappingPtr *const mappings,
> +			          int maxmappings);
> +int                     virNetworkFreeDHCPHostMappings
> +                                 (virNetworkDHCPHostMappingPtr *const mappings,
> +			          int maxmappings);

  Hum, do we really need to expose this structure at the API level, since we
use it only for listing. Since everything is provided as strings why not 
use something like

     int virNetworkListDHCPHostMappings (virNetworkPtr network,
                                         int maxmappings,
                                         char **hwaddrtab,
					 char **ipaddrtab,
					 char **hostnametab);

  This also avoids the free function too, same functionality, quite a simpler
interface.
  Also I don't understand the 'const' in that function and what 
virNetworkFreeDHCPHostMappings is supposed to be used for. If mappings 
is allocated by the user, it doesn't need a library deallocator, if it's
allocated by the library I can't see how it's const, the API confuses me 
I must admit.


Daniel

-- 
Red Hat Virtualization group http://redhat.com/virtualization/
Daniel Veillard      | virtualization library  http://libvirt.org/
veillard at redhat.com  | libxml GNOME XML XSLT toolkit  http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine  http://rpmfind.net/




More information about the libvir-list mailing list