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;
if (--ic->ref < 1) {
xic_all = g_slist_remove(xic_all, ic);
XDestroyIC(ic->xic);
- g_free(ic);
+ g_slice_free(ObtIC, ic);
}
}
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;
{
ObtMainLoopXHandlerType *h;
- h = g_new(ObtMainLoopXHandlerType, 1);
+ h = g_slice_new(ObtMainLoopXHandlerType);
h->loop = loop;
h->func = handler;
h->data = data;
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);
}
}
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;
g_slist_delete_link(loop->signal_handlers[i], it);
if (h->destroy) h->destroy(h->data);
- g_free(h);
+ g_slice_free(ObtMainLoopSignalHandlerType, h);
}
}
}
{
ObtMainLoopFdHandlerType *h;
- h = g_new(ObtMainLoopFdHandlerType, 1);
+ h = g_slice_new(ObtMainLoopFdHandlerType);
h->loop = loop;
h->fd = fd;
h->func = handler;
if (h->destroy)
h->destroy(h->data);
+ g_slice_free(ObtMainLoopFdHandlerType, h);
}
void obt_main_loop_fd_remove(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 */
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;
}
} 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
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)
{
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);
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,
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);
}
}
return;
}
- c = g_new(struct Callback, 1);
+ c = g_slice_new(struct Callback);
c->tag = g_strdup(tag);
c->func = func;
c->data = data;