diff options
author | Ian Campbell <ian.campbell@citrix.com> | 2010-08-31 19:14:57 +0100 |
---|---|---|
committer | Ian Campbell <ian.campbell@citrix.com> | 2010-08-31 19:14:57 +0100 |
commit | b89c3d320f3e21c46e28d127ffb120210a36bd77 (patch) | |
tree | 392d83e6c157f2ffdcefdea12cd3a6881507b10b /tools/libxl/gentypes.py | |
parent | 5b67996cc6b306a44d2c9a4f04036234762f1789 (diff) | |
download | xen-b89c3d320f3e21c46e28d127ffb120210a36bd77.tar.gz xen-b89c3d320f3e21c46e28d127ffb120210a36bd77.tar.bz2 xen-b89c3d320f3e21c46e28d127ffb120210a36bd77.zip |
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@citrix.com>
Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Diffstat (limited to 'tools/libxl/gentypes.py')
-rw-r--r-- | tools/libxl/gentypes.py | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/tools/libxl/gentypes.py b/tools/libxl/gentypes.py index 52cbf1f25b..538a1c3304 100644 --- a/tools/libxl/gentypes.py +++ b/tools/libxl/gentypes.py @@ -64,6 +64,11 @@ def libxl_C_type_destroy(ty, v, reference, indent = " ", parent = None): 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, reference, indent = " ", parent = None): 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, reference, indent = " ", parent = None): 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) |