use g_slice_new() instead of g_new() part 2

This commit is contained in:
Dana Jansens 2010-02-12 13:55:26 -05:00
parent 1d57f7b085
commit 4f93731cdb
8 changed files with 29 additions and 29 deletions

View file

@ -102,7 +102,7 @@ ObActionsDefinition* do_register(const gchar *name,
return NULL;
}
def = g_new(ObActionsDefinition, 1);
def = g_slice_new(ObActionsDefinition);
def->ref = 1;
def->name = g_strdup(name);
def->free = free;
@ -164,7 +164,7 @@ static void actions_definition_unref(ObActionsDefinition *def)
{
if (def && --def->ref == 0) {
g_free(def->name);
g_free(def);
g_slice_free(ObActionsDefinition, def);
}
}
@ -184,7 +184,7 @@ static ObActionsAct* actions_build_act_from_string(const gchar *name)
/* if we found the action */
if (def) {
act = g_new(ObActionsAct, 1);
act = g_slice_new(ObActionsAct);
act->ref = 1;
act->def = def;
actions_definition_ref(act->def);
@ -268,7 +268,7 @@ void actions_act_unref(ObActionsAct *act)
act->def->free(act->options);
/* unref the definition */
actions_definition_unref(act->def);
g_free(act);
g_slice_free(ObActionsAct, act);
}
}

View file

@ -116,7 +116,7 @@ static void desk_menu_destroy(ObMenu *menu, gpointer data)
{
DesktopData *d = data;
g_free(d);
g_slice_free(DesktopData, d);
desktop_menus = g_slist_remove(desktop_menus, menu);
}
@ -136,7 +136,7 @@ static gboolean self_update(ObMenuFrame *frame, gpointer data)
for (i = 0; i < screen_num_desktops; ++i) {
ObMenu *submenu;
gchar *name = g_strdup_printf("%s-%u", MENU_NAME, i);
DesktopData *ddata = g_new(DesktopData, 1);
DesktopData *ddata = g_slice_new(DesktopData);
ddata->desktop = i;
submenu = menu_new(name, screen_desktop_names[i], FALSE, ddata);

View file

@ -811,7 +811,7 @@ void event_enter_client(ObClient *client)
obt_main_loop_timeout_remove(ob_main_loop, focus_delay_func);
data = g_new(ObFocusDelayData, 1);
data = g_slice_new(ObFocusDelayData);
data->client = client;
data->time = event_curtime;
data->serial = event_curserial;
@ -846,7 +846,7 @@ void event_leave_client(ObClient *client)
obt_main_loop_timeout_remove(ob_main_loop, unfocus_delay_func);
data = g_new(ObFocusDelayData, 1);
data = g_slice_new(ObFocusDelayData);
data->client = client;
data->time = event_curtime;
data->serial = event_curserial;
@ -1997,7 +1997,7 @@ static gboolean event_handle_user_input(ObClient *client, XEvent *e)
static void focus_delay_dest(gpointer data)
{
g_free(data);
g_slice_free(ObFocusDelayData, data);
}
static gboolean focus_delay_cmp(gconstpointer d1, gconstpointer d2)
@ -2059,7 +2059,7 @@ static void event_ignore_enter_range(gulong start, gulong end)
g_assert(start != 0);
g_assert(end != 0);
r = g_new(ObSerialRange, 1);
r = g_slice_new(ObSerialRange);
r->start = start;
r->end = end;
ignore_serials = g_slist_prepend(ignore_serials, r);
@ -2094,7 +2094,7 @@ static gboolean is_enter_focus_event_ignored(gulong serial)
if ((glong)(serial - r->end) > 0) {
/* past the end */
ignore_serials = g_slist_delete_link(ignore_serials, it);
g_free(r);
g_slice_free(ObSerialRange, r);
}
else if ((glong)(serial - r->start) >= 0)
return TRUE;

View file

@ -246,7 +246,7 @@ static void popup_target_free(ObFocusCyclePopupTarget *t)
g_free(t->text);
XDestroyWindow(obt_display, t->iconwin);
XDestroyWindow(obt_display, t->textwin);
g_free(t);
g_slice_free(ObFocusCyclePopupTarget, t);
}
static gboolean popup_setup(ObFocusCyclePopup *p, gboolean create_targets,
@ -313,7 +313,7 @@ static gboolean popup_setup(ObFocusCyclePopup *p, gboolean create_targets,
g_free(text);
} else {
ObFocusCyclePopupTarget *t =
g_new(ObFocusCyclePopupTarget, 1);
g_slice_new(ObFocusCyclePopupTarget);
t->client = ft;
t->text = text;

View file

@ -45,7 +45,7 @@ ObGroup *group_add(Window leader, ObClient *client)
self = g_hash_table_lookup(group_map, &leader);
if (self == NULL) {
self = g_new(ObGroup, 1);
self = g_slice_new(ObGroup);
self->leader = leader;
self->members = NULL;
g_hash_table_insert(group_map, &self->leader, self);
@ -61,6 +61,6 @@ void group_remove(ObGroup *self, ObClient *client)
self->members = g_slist_remove(self->members, client);
if (self->members == NULL) {
g_hash_table_remove(group_map, &self->leader);
g_free(self);
g_slice_free(ObGroup, self);
}
}

View file

@ -158,7 +158,7 @@ static gboolean place_random(ObClient *client, gint *x, gint *y)
static GSList* area_add(GSList *list, Rect *a)
{
Rect *r = g_new(Rect, 1);
Rect *r = g_slice_new(Rect);
*r = *a;
return g_slist_prepend(list, r);
}
@ -210,7 +210,7 @@ static GSList* area_remove(GSList *list, Rect *a)
}
/* 'r' is not being added to the result list, so free it */
g_free(r);
g_slice_free(Rect, r);
}
}
g_slist_free(list);
@ -332,7 +332,7 @@ static gboolean place_nooverlap(ObClient *c, gint *x, gint *y)
}
while (spaces) {
g_free(spaces->data);
g_slice_free(Rect, spaces->data);
spaces = g_slist_delete_link(spaces, spaces);
}
}

View file

@ -31,7 +31,7 @@
ObPopup *popup_new(void)
{
XSetWindowAttributes attrib;
ObPopup *self = g_new0(ObPopup, 1);
ObPopup *self = g_slice_new0(ObPopup);
self->obwin.type = OB_WINDOW_CLASS_INTERNAL;
self->gravity = NorthWestGravity;
@ -72,7 +72,7 @@ void popup_free(ObPopup *self)
RrAppearanceFree(self->a_text);
window_remove(self->bg);
stacking_remove(self);
g_free(self);
g_slice_free(ObPopup, self);
}
}
@ -342,7 +342,7 @@ ObIconPopup *icon_popup_new(void)
{
ObIconPopup *self;
self = g_new0(ObIconPopup, 1);
self = g_slice_new0(ObIconPopup);
self->popup = popup_new();
self->a_icon = RrAppearanceCopy(ob_rr_theme->a_clear_tex);
self->icon = XCreateWindow(obt_display, self->popup->bg,
@ -364,7 +364,7 @@ void icon_popup_free(ObIconPopup *self)
XDestroyWindow(obt_display, self->icon);
RrAppearanceFree(self->a_icon);
popup_free(self->popup);
g_free(self);
g_slice_free(ObIconPopup, self);
}
}
@ -501,7 +501,7 @@ ObPagerPopup *pager_popup_new(void)
{
ObPagerPopup *self;
self = g_new(ObPagerPopup, 1);
self = g_slice_new(ObPagerPopup);
self->popup = popup_new();
self->desks = 0;
@ -527,7 +527,7 @@ void pager_popup_free(ObPagerPopup *self)
RrAppearanceFree(self->hilight);
RrAppearanceFree(self->unhilight);
popup_free(self->popup);
g_free(self);
g_slice_free(ObPagerPopup, self);
}
}

View file

@ -376,7 +376,7 @@ static void session_setup_restart_command(void)
static ObSMSaveData *sm_save_get_data(void)
{
ObSMSaveData *savedata = g_new0(ObSMSaveData, 1);
ObSMSaveData *savedata = g_slice_new0(ObSMSaveData);
/* save the active desktop and client.
we don't bother to preemptively save the other desktop state like
number and names of desktops, cuz those shouldn't be changing during
@ -398,7 +398,7 @@ static void sm_save_yourself_2(SmcConn conn, SmPointer data)
if (savedata == NULL)
savedata = sm_save_get_data();
success = session_save_to_file(savedata);
g_free(savedata);
g_slice_free(ObSMSaveData, savedata);
/* tell the session manager how to restore this state */
if (success) session_setup_restart_command();
@ -443,7 +443,7 @@ static void sm_save_yourself(SmcConn conn, SmPointer data, gint save_type,
if (!SmcRequestSaveYourselfPhase2(conn, sm_save_yourself_2, savedata)) {
ob_debug_type(OB_DEBUG_SM, "Requst for phase 2 failed");
g_free(savedata);
g_slice_free(ObSMSaveData, savedata);
SmcSaveYourselfDone(conn, FALSE);
}
}
@ -630,7 +630,7 @@ static void session_state_free(ObSessionState *state)
g_free(state->class);
g_free(state->role);
g_free(state);
g_slice_free(ObSessionState, state);
}
}
@ -731,7 +731,7 @@ static void session_load_file(const gchar *path)
{
ObSessionState *state;
state = g_new0(ObSessionState, 1);
state = g_slice_new0(ObSessionState);
if (!obt_xml_attr_string(node, "id", &state->id))
if (!obt_xml_attr_string(node, "command", &state->command))