# HG changeset patch
# User Ian Campbell <ian.campbell@xxxxxxxxxx>
# Date 1282923129 -3600
# Node ID 6b7c034c4710056bcc7ecba46971c24f99683236
# Parent 228640a1efbb120939de2718e7a6c997cac2880f
libxl: builtin list types should be pass-by-reference
This makes all _destroy functions consistent wrt freeing the actual
reference passed in. Previously we were relying on the reference
contained within the type itself which worked but was semantically a
little confusing.
Signed-off-by: Ian Campbell <ian.campbell@xxxxxxxxxx>
diff -r 228640a1efbb -r 6b7c034c4710 tools/libxl/libxl.c
--- a/tools/libxl/libxl.c Fri Aug 27 16:27:36 2010 +0100
+++ b/tools/libxl/libxl.c Fri Aug 27 16:32:09 2010 +0100
@@ -71,9 +71,10 @@ int libxl_ctx_free(libxl_ctx *ctx)
return 0;
}
-void libxl_string_list_destroy(libxl_string_list sl)
+void libxl_string_list_destroy(libxl_string_list *psl)
{
int i;
+ libxl_string_list sl = *psl;
if (!sl)
return;
@@ -83,9 +84,10 @@ void libxl_string_list_destroy(libxl_str
free(sl);
}
-void libxl_key_value_list_destroy(libxl_key_value_list kvl)
+void libxl_key_value_list_destroy(libxl_key_value_list *pkvl)
{
int i;
+ libxl_key_value_list kvl = *pkvl;
if (!kvl)
return;
diff -r 228640a1efbb -r 6b7c034c4710 tools/libxl/libxl.h
--- a/tools/libxl/libxl.h Fri Aug 27 16:27:36 2010 +0100
+++ b/tools/libxl/libxl.h Fri Aug 27 16:32:09 2010 +0100
@@ -234,8 +234,8 @@ int libxl_domain_preserve(libxl_ctx *ctx
int libxl_domain_preserve(libxl_ctx *ctx, uint32_t domid,
libxl_domain_create_info *info, const char *name_suffix, libxl_uuid new_uuid);
/* destructors for builtin data types */
-void libxl_string_list_destroy(libxl_string_list sl);
-void libxl_key_value_list_destroy(libxl_key_value_list kvl);
+void libxl_string_list_destroy(libxl_string_list *sl);
+void libxl_key_value_list_destroy(libxl_key_value_list *kvl);
void libxl_file_reference_destroy(libxl_file_reference *f);
/*
diff -r 228640a1efbb -r 6b7c034c4710 tools/libxl/libxl.idl
--- a/tools/libxl/libxl.idl Fri Aug 27 16:27:36 2010 +0100
+++ b/tools/libxl/libxl.idl Fri Aug 27 16:32:09 2010 +0100
@@ -12,8 +12,8 @@ libxl_disk_phystype = Builtin("disk_phys
libxl_disk_phystype = Builtin("disk_phystype")
libxl_nic_type = Builtin("nic_type")
-libxl_string_list = Builtin("string_list",
destructor_fn="libxl_string_list_destroy")
-libxl_key_value_list = Builtin("key_value_list",
destructor_fn="libxl_key_value_list_destroy")
+libxl_string_list = Builtin("string_list",
destructor_fn="libxl_string_list_destroy", passby=PASS_BY_REFERENCE)
+libxl_key_value_list = Builtin("key_value_list",
destructor_fn="libxl_key_value_list_destroy", passby=PASS_BY_REFERENCE)
libxl_cpumap = Builtin("cpumap", destructor_fn="free")
diff -r 228640a1efbb -r 6b7c034c4710 tools/libxl/libxltypes.py
--- a/tools/libxl/libxltypes.py Fri Aug 27 16:27:36 2010 +0100
+++ b/tools/libxl/libxltypes.py Fri Aug 27 16:32:09 2010 +0100
@@ -182,6 +182,8 @@ def parse(f):
globs[n] = t
elif isinstance(t,type(object)) and issubclass(t, Type):
globs[n] = t
+ elif n in ['PASS_BY_REFERENCE', 'PASS_BY_VALUE']:
+ globs[n] = t
try:
execfile(f, globs, locs)
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
|