]> Dogcows Code - chaz/openbox/commitdiff
use g_slice_new() instead of g_new() part 3
authorDana Jansens <danakj@orodu.net>
Fri, 12 Feb 2010 19:03:24 +0000 (14:03 -0500)
committerDana Jansens <danakj@orodu.net>
Fri, 12 Feb 2010 19:03:24 +0000 (14:03 -0500)
obt/keyboard.c
obt/mainloop.c
obt/xevent.c
obt/xml.c

index f7a0f3bbee80cd83a3c12c336c33b824940fd006..2d3a0553d7a864e9a8c55bf130b110961e72e106 100644 (file)
@@ -402,7 +402,7 @@ ObtIC* obt_keyboard_context_new(Window client, Window focus)
 
     g_return_val_if_fail(client != None && focus != None, NULL);
 
-    ic = g_new(ObtIC, 1);
+    ic = g_slice_new(ObtIC);
     ic->ref = 1;
     ic->client = client;
     ic->focus = focus;
@@ -424,6 +424,6 @@ void obt_keyboard_context_unref(ObtIC *ic)
     if (--ic->ref < 1) {
         xic_all = g_slist_remove(xic_all, ic);
         XDestroyIC(ic->xic);
-        g_free(ic);
+        g_slice_free(ObtIC, ic);
     }
 }
index ebc9e96a8260a4a0be3f49fb033d29da3ab5b2be..c0b9bb597e92922d0a5823ea25144e7a847fd096 100644 (file)
@@ -223,7 +223,7 @@ void obt_main_loop_unref(ObtMainLoop *loop)
         for (it = loop->timers; it; it = g_slist_next(it)) {
             ObtMainLoopTimer *t = it->data;
             if (t->destroy) t->destroy(t->data);
-            g_free(t);
+            g_slice_free(ObtMainLoopTimer, t);
         }
         g_slist_free(loop->timers);
         loop->timers = NULL;
@@ -348,7 +348,7 @@ void obt_main_loop_x_add(ObtMainLoop *loop,
 {
     ObtMainLoopXHandlerType *h;
 
-    h = g_new(ObtMainLoopXHandlerType, 1);
+    h = g_slice_new(ObtMainLoopXHandlerType);
     h->loop = loop;
     h->func = handler;
     h->data = data;
@@ -377,7 +377,7 @@ void obt_main_loop_x_remove(ObtMainLoop *loop,
         if (h->func == handler) {
             loop->x_handlers = g_slist_delete_link(loop->x_handlers, it);
             if (h->destroy) h->destroy(h->data);
-            g_free(h);
+            g_slice_free(ObtMainLoopXHandlerType, h);
         }
     }
 
@@ -425,7 +425,7 @@ void obt_main_loop_signal_add(ObtMainLoop *loop,
 
     g_return_if_fail(signal < NUM_SIGNALS);
 
-    h = g_new(ObtMainLoopSignalHandlerType, 1);
+    h = g_slice_new(ObtMainLoopSignalHandlerType);
     h->loop = loop;
     h->signal = signal;
     h->func = handler;
@@ -473,7 +473,7 @@ void obt_main_loop_signal_remove(ObtMainLoop *loop,
                     g_slist_delete_link(loop->signal_handlers[i], it);
                 if (h->destroy) h->destroy(h->data);
 
-                g_free(h);
+                g_slice_free(ObtMainLoopSignalHandlerType, h);
             }
         }
     }
@@ -505,7 +505,7 @@ void obt_main_loop_fd_add(ObtMainLoop *loop,
 {
     ObtMainLoopFdHandlerType *h;
 
-    h = g_new(ObtMainLoopFdHandlerType, 1);
+    h = g_slice_new(ObtMainLoopFdHandlerType);
     h->loop = loop;
     h->fd = fd;
     h->func = handler;
@@ -525,6 +525,7 @@ static void fd_handler_destroy(gpointer data)
 
     if (h->destroy)
         h->destroy(h->data);
+    g_slice_free(ObtMainLoopFdHandlerType, h);
 }
 
 void obt_main_loop_fd_remove(ObtMainLoop *loop,
@@ -567,7 +568,7 @@ void obt_main_loop_timeout_add(ObtMainLoop *loop,
                                GEqualFunc cmp,
                                GDestroyNotify notify)
 {
-    ObtMainLoopTimer *t = g_new(ObtMainLoopTimer, 1);
+    ObtMainLoopTimer *t = g_slice_new(ObtMainLoopTimer);
 
     g_assert(microseconds > 0); /* if it's 0 it'll cause an infinite loop */
 
@@ -655,7 +656,7 @@ static void timer_dispatch(ObtMainLoop *loop, GTimeVal **wait)
             loop->timers = g_slist_delete_link(loop->timers, it);
             if (curr->destroy)
                 curr->destroy(curr->data);
-            g_free(curr);
+            g_slice_free(ObtMainLoopTimer, curr);
             continue;
         }
 
@@ -676,7 +677,7 @@ static void timer_dispatch(ObtMainLoop *loop, GTimeVal **wait)
         } else {
             if (curr->destroy)
                 curr->destroy(curr->data);
-            g_free(curr);
+            g_slice_free(ObtMainLoopTimer, curr);
         }
 
         /* the timer queue has been shuffled, start from the beginning
index 1cc32a94d3eb32deeba960b59cee5eb688fb7c7f..21beb9301b40218a810998ce8653c4713b561b90 100644 (file)
@@ -43,6 +43,7 @@ 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)
 {
@@ -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);
index da3e866b6f5ea452ded04a1692335200597a0b06..ffff1500e16d341b430584de1b132a027a5726d1 100644 (file)
--- a/obt/xml.c
+++ b/obt/xml.c
@@ -52,12 +52,12 @@ struct _ObtXmlInst {
 static void destfunc(struct Callback *c)
 {
     g_free(c->tag);
-    g_free(c);
+    g_slice_free(struct Callback, c);
 }
 
 ObtXmlInst* obt_xml_instance_new(void)
 {
-    ObtXmlInst *i = g_new(ObtXmlInst, 1);
+    ObtXmlInst *i = g_slice_new(ObtXmlInst);
     i->ref = 1;
     i->xdg_paths = obt_paths_new();
     i->callbacks = g_hash_table_new_full(g_str_hash, g_str_equal, NULL,
@@ -78,7 +78,7 @@ void obt_xml_instance_unref(ObtXmlInst *i)
     if (i && --i->ref == 0) {
         obt_paths_unref(i->xdg_paths);
         g_hash_table_destroy(i->callbacks);
-        g_free(i);
+        g_slice_free(ObtXmlInst, i);
     }
 }
 
@@ -104,7 +104,7 @@ void obt_xml_register(ObtXmlInst *i, const gchar *tag,
         return;
     }
 
-    c = g_new(struct Callback, 1);
+    c = g_slice_new(struct Callback);
     c->tag = g_strdup(tag);
     c->func = func;
     c->data = data;
This page took 0.031613 seconds and 4 git commands to generate.