WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] [PATCH 3 of 3] libxl: builtin list types should be pass-by-r

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] [PATCH 3 of 3] libxl: builtin list types should be pass-by-reference
From: Ian Campbell <ian.campbell@xxxxxxxxxx>
Date: Fri, 27 Aug 2010 16:32:32 +0100
Cc: Ian Campbell <ian.campbell@xxxxxxxxxx>
Delivery-date: Fri, 27 Aug 2010 08:36:50 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <patchbomb.1282923149@xxxxxxxxxxxxxxxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
# 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

<Prev in Thread] Current Thread [Next in Thread>