[Xcb] [PATCH lib] c_client.py: Do not create pointers in unions

Daniel Martin consume.noise at gmail.com
Fri Dec 28 14:40:29 PST 2012


Do not create pointers in unions for fields of variadic length.

Signed-off-by: Daniel Martin <consume.noise at gmail.com>
---

With this patch xcb_xkb_doodad_t in xkb.h will change:

 typedef union xcb_xkb_doodad_t {
     xcb_xkb_common_doodad_t    common; /**<  */
     xcb_xkb_shape_doodad_t     shape; /**<  */
-    xcb_xkb_text_doodad_t     *text; /**<  */
+    xcb_xkb_text_doodad_t      text; /**<  */
     xcb_xkb_indicator_doodad_t indicator; /**<  */
-    xcb_xkb_logo_doodad_t     *logo; /**<  */
+    xcb_xkb_logo_doodad_t      logo; /**<  */
 } xcb_xkb_doodad_t;


 src/c_client.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/c_client.py b/src/c_client.py
index 6b7f5c2..3d521a6 100644
--- a/src/c_client.py
+++ b/src/c_client.py
@@ -1787,12 +1787,12 @@ def _c_complex(self):
     for field in struct_fields:
         length = len(field.c_field_type)
         # account for '*' pointer_spec
-        if not field.type.fixed_size():
+        if not field.type.fixed_size() and not self.is_union:
             length += 1
         maxtypelen = max(maxtypelen, length)
 
     def _c_complex_field(self, field, space=''):
-        if (field.type.fixed_size() or 
+        if (field.type.fixed_size() or self.is_union or
             # in case of switch with switch children, don't make the field a pointer
             # necessary for unserialize to work
             (self.is_switch and field.type.is_switch)):
-- 
1.8.0.2



More information about the Xcb mailing list