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

[Xen-devel] [PATCH 1 of 3] libxl: correctly free Reference types in autogenerated destroy functions



# HG changeset patch
# User Ian Campbell <ian.campbell@xxxxxxxxxx>
# Date 1282922856 -3600
# Node ID 75a3469cfac671cbf0271527d245e29b34b0e60f
# Parent  76b574e9805f6154f3e651e3610befd7847f97e3
libxl: correctly free Reference types in autogenerated destroy functions

References types should be recursively destroyed and then the actual
reference itself should be destroyed.

Signed-off-by: Ian Campbell <ian.campbell@xxxxxxxxxx>

diff -r 76b574e9805f -r 75a3469cfac6 tools/libxl/gentypes.py
--- a/tools/libxl/gentypes.py   Fri Aug 27 16:27:36 2010 +0100
+++ b/tools/libxl/gentypes.py   Fri Aug 27 16:27:36 2010 +0100
@@ -64,6 +64,11 @@ def libxl_C_type_destroy(ty, v, referenc
         deref = v + "->"
     else:
         deref = v + "."
+        
+    if ty.passby == libxltypes.PASS_BY_REFERENCE and not reference:
+        makeref = "&"
+    else:
+        makeref = ""
 
     s = ""
     if isinstance(ty, libxltypes.KeyedUnion):
@@ -76,6 +81,8 @@ def libxl_C_type_destroy(ty, v, referenc
             s += "}\n"
     elif isinstance(ty, libxltypes.Reference):
         s += libxl_C_type_destroy(ty.ref_type, v, True, indent, v)
+        if ty.destructor_fn is not None:
+            s += "%s(%s);\n" % (ty.destructor_fn, makeref + v)
     elif isinstance(ty, libxltypes.Struct) and (parent is None or 
ty.destructor_fn is None):
         for f in [f for f in ty.fields if not f.const]:
 
@@ -84,11 +91,6 @@ def libxl_C_type_destroy(ty, v, referenc
             else:
                 s += libxl_C_type_destroy(f.type, deref + f.name, False, "", 
deref)
     else:
-        if ty.passby == libxltypes.PASS_BY_REFERENCE and not reference:
-            makeref = "&"
-        else:
-            makeref = ""
-
         if ty.destructor_fn is not None:
             s += "%s(%s);\n" % (ty.destructor_fn, makeref + v)
             

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
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®.