]> Dogcows Code - chaz/openbox/blobdiff - obt/xevent.c
avoid ascii control characters in strings
[chaz/openbox] / obt / xevent.c
index 1cc32a94d3eb32deeba960b59cee5eb688fb7c7f..1077165766935301c2ac0551491c92d9dd2c6b53 100644 (file)
@@ -43,12 +43,13 @@ struct _ObtXEventBinding
 static void xevent_handler(const XEvent *e, gpointer data);
 static guint window_hash(Window *w) { return *w; }
 static gboolean window_comp(Window *w1, Window *w2) { return *w1 == *w2; }
+static void binding_free(gpointer b);
 
 ObtXEventHandler* xevent_new(void)
 {
     ObtXEventHandler *h;
 
-    h = g_new0(ObtXEventHandler, 1);
+    h = g_slice_new0(ObtXEventHandler);
     h->ref = 1;
 
     return h;
@@ -70,7 +71,7 @@ void xevent_unref(ObtXEventHandler *h)
             g_hash_table_destroy(h->bindings[i]);
         g_free(h->bindings);
 
-        obt_free0(h, ObtXEventHandler, 1);
+        g_slice_free(ObtXEventHandler, h);
     }
 }
 
@@ -94,17 +95,22 @@ void xevent_set_handler(ObtXEventHandler *h, gint type, Window win,
         for (i = h->num_event_types; i < type + 1; ++i)
             h->bindings[i] = g_hash_table_new_full((GHashFunc)window_hash,
                                                    (GEqualFunc)window_comp,
-                                                   NULL, g_free);
+                                                   NULL, binding_free);
         h->num_event_types = type + 1;
     }
 
-    b = g_new(ObtXEventBinding, 1);
+    b = g_slice_new(ObtXEventBinding);
     b->win = win;
     b->func = func;
     b->data = data;
     g_hash_table_replace(h->bindings[type], &b->win, b);
 }
 
+static void binding_free(gpointer b)
+{
+    g_slice_free(ObtXEventBinding, b);
+}
+
 void xevent_remove_handler(ObtXEventHandler *h, gint type, Window win)
 {
     g_assert(type < h->num_event_types);
This page took 0.020918 seconds and 4 git commands to generate.