[Xcb-commit] icccm

Julien Danjou jdanjou at kemper.freedesktop.org
Sat Apr 4 04:38:40 PDT 2009


 icccm/icccm.c     |   21 ++++++++++++++-------
 icccm/xcb_icccm.h |   11 +++++++++++
 2 files changed, 25 insertions(+), 7 deletions(-)

New commits:
commit 803deddb31931211099309d78d3bb6bcff29487b
Author: Julien Danjou <julien at danjou.info>
Date:   Sat Apr 4 13:38:12 2009 +0200

    icccm: add xcb_get_wm_class_from_reply()
    
    Signed-off-by: Julien Danjou <julien at danjou.info>

diff --git a/icccm/icccm.c b/icccm/icccm.c
index a1d7502..d818d7e 100644
--- a/icccm/icccm.c
+++ b/icccm/icccm.c
@@ -238,16 +238,11 @@ xcb_get_wm_class_unchecked(xcb_connection_t *c, xcb_window_t window)
 }
 
 uint8_t
-xcb_get_wm_class_reply(xcb_connection_t *c, xcb_get_property_cookie_t cookie,
-                       xcb_get_wm_class_reply_t *prop, xcb_generic_error_t **e)
+xcb_get_wm_class_from_reply(xcb_get_wm_class_reply_t *prop,
+                            xcb_get_property_reply_t *reply)
 {
-  xcb_get_property_reply_t *reply = xcb_get_property_reply(c, cookie, e);
-
   if(!reply || reply->type != STRING || reply->format != 8)
-  {
-    free(reply);
     return 0;
-  }
 
   prop->_reply = reply;
   prop->instance_name = (char *) xcb_get_property_value(prop->_reply);
@@ -261,6 +256,18 @@ xcb_get_wm_class_reply(xcb_connection_t *c, xcb_get_property_cookie_t cookie,
   return 1;
 }
 
+uint8_t
+xcb_get_wm_class_reply(xcb_connection_t *c, xcb_get_property_cookie_t cookie,
+                       xcb_get_wm_class_reply_t *prop, xcb_generic_error_t **e)
+{
+  xcb_get_property_reply_t *reply = xcb_get_property_reply(c, cookie, e);
+  uint8_t ret = xcb_get_wm_class_from_reply(prop, reply);
+  /* if reply parsing failed, free the reply to avoid mem leak */
+  if(!ret)
+      free(reply);
+  return ret;
+}
+
 void xcb_get_wm_class_reply_wipe(xcb_get_wm_class_reply_t *prop)
 {
   free(prop->_reply);
diff --git a/icccm/xcb_icccm.h b/icccm/xcb_icccm.h
index 745f920..5358d89 100644
--- a/icccm/xcb_icccm.h
+++ b/icccm/xcb_icccm.h
@@ -327,6 +327,17 @@ xcb_get_property_cookie_t xcb_get_wm_class(xcb_connection_t *c,
 xcb_get_property_cookie_t xcb_get_wm_class_unchecked(xcb_connection_t *c,
                                                      xcb_window_t window);
 
+
+/**
+ * @brief Fill give structure with the WM_CLASS property of a window.
+ * @param prop The property structur to fill.
+ * @param reply The property request reply.
+ * @return Return 1 on success, 0 otherwise.
+ */
+uint8_t
+xcb_get_wm_class_from_reply(xcb_get_wm_class_reply_t *prop,
+                            xcb_get_property_reply_t *reply);
+
 /**
  * @brief Fill given structure with the WM_CLASS property of a window.
  * @param c The connection to the X server.


More information about the xcb-commit mailing list