using g_slice_new() instead of g_new() part 1
This commit is contained in:
parent
98c86118ca
commit
1d57f7b085
6 changed files with 30 additions and 24 deletions
|
@ -174,8 +174,8 @@ static gboolean run_func(ObActionsData *data, gpointer options)
|
||||||
client_configure(c, x, y, w, h, TRUE, TRUE, FALSE);
|
client_configure(c, x, y, w, h, TRUE, TRUE, FALSE);
|
||||||
actions_client_move(data, FALSE);
|
actions_client_move(data, FALSE);
|
||||||
|
|
||||||
g_free(area);
|
g_slice_free(Rect, area);
|
||||||
g_free(carea);
|
g_slice_free(Rect, carea);
|
||||||
}
|
}
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
|
@ -150,7 +150,7 @@ static void client_call_notifies(ObClient *self, GSList *list)
|
||||||
|
|
||||||
void client_add_destroy_notify(ObClientCallback func, gpointer data)
|
void client_add_destroy_notify(ObClientCallback func, gpointer data)
|
||||||
{
|
{
|
||||||
ClientCallback *d = g_new(ClientCallback, 1);
|
ClientCallback *d = g_slice_new(ClientCallback);
|
||||||
d->func = func;
|
d->func = func;
|
||||||
d->data = data;
|
d->data = data;
|
||||||
client_destroy_notifies = g_slist_prepend(client_destroy_notifies, d);
|
client_destroy_notifies = g_slist_prepend(client_destroy_notifies, d);
|
||||||
|
@ -163,7 +163,7 @@ void client_remove_destroy_notify(ObClientCallback func)
|
||||||
for (it = client_destroy_notifies; it; it = g_slist_next(it)) {
|
for (it = client_destroy_notifies; it; it = g_slist_next(it)) {
|
||||||
ClientCallback *d = it->data;
|
ClientCallback *d = it->data;
|
||||||
if (d->func == func) {
|
if (d->func == func) {
|
||||||
g_free(d);
|
g_slice_free(ClientCallback, d);
|
||||||
client_destroy_notifies =
|
client_destroy_notifies =
|
||||||
g_slist_delete_link(client_destroy_notifies, it);
|
g_slist_delete_link(client_destroy_notifies, it);
|
||||||
break;
|
break;
|
||||||
|
@ -221,7 +221,7 @@ void client_manage(Window window, ObPrompt *prompt)
|
||||||
|
|
||||||
/* create the ObClient struct, and populate it from the hints on the
|
/* create the ObClient struct, and populate it from the hints on the
|
||||||
window */
|
window */
|
||||||
self = g_new0(ObClient, 1);
|
self = g_slice_new0(ObClient);
|
||||||
self->obwin.type = OB_WINDOW_CLASS_CLIENT;
|
self->obwin.type = OB_WINDOW_CLASS_CLIENT;
|
||||||
self->window = window;
|
self->window = window;
|
||||||
self->prompt = prompt;
|
self->prompt = prompt;
|
||||||
|
@ -347,7 +347,7 @@ void client_manage(Window window, ObPrompt *prompt)
|
||||||
place.x = r->x;
|
place.x = r->x;
|
||||||
place.y = r->y;
|
place.y = r->y;
|
||||||
ob_debug("Moving buggy app from (0,0) to (%d,%d)", r->x, r->y);
|
ob_debug("Moving buggy app from (0,0) to (%d,%d)", r->x, r->y);
|
||||||
g_free(r);
|
g_slice_free(Rect, r);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* make sure the window is visible. */
|
/* make sure the window is visible. */
|
||||||
|
@ -420,7 +420,7 @@ void client_manage(Window window, ObPrompt *prompt)
|
||||||
place.width -= self->frame->size.left + self->frame->size.right;
|
place.width -= self->frame->size.left + self->frame->size.right;
|
||||||
place.height -= self->frame->size.top + self->frame->size.bottom;
|
place.height -= self->frame->size.top + self->frame->size.bottom;
|
||||||
|
|
||||||
g_free(a);
|
g_slice_free(Rect, a);
|
||||||
}
|
}
|
||||||
|
|
||||||
ob_debug("placing window 0x%x at %d, %d with size %d x %d. "
|
ob_debug("placing window 0x%x at %d, %d with size %d x %d. "
|
||||||
|
@ -518,7 +518,7 @@ ObClient *client_fake_manage(Window window)
|
||||||
|
|
||||||
/* do this minimal stuff to figure out the client's decorations */
|
/* do this minimal stuff to figure out the client's decorations */
|
||||||
|
|
||||||
self = g_new0(ObClient, 1);
|
self = g_slice_new0(ObClient);
|
||||||
self->window = window;
|
self->window = window;
|
||||||
|
|
||||||
client_get_all(self, FALSE);
|
client_get_all(self, FALSE);
|
||||||
|
@ -695,7 +695,7 @@ void client_unmanage(ObClient *self)
|
||||||
g_free(self->role);
|
g_free(self->role);
|
||||||
g_free(self->client_machine);
|
g_free(self->client_machine);
|
||||||
g_free(self->sm_client_id);
|
g_free(self->sm_client_id);
|
||||||
g_free(self);
|
g_slice_free(ObClient, self);
|
||||||
}
|
}
|
||||||
|
|
||||||
void client_fake_unmanage(ObClient *self)
|
void client_fake_unmanage(ObClient *self)
|
||||||
|
@ -1085,7 +1085,7 @@ gboolean client_find_onscreen(ObClient *self, gint *x, gint *y, gint w, gint h,
|
||||||
if (rudeb && !self->strut.bottom && *y + fh > a->y + a->height)
|
if (rudeb && !self->strut.bottom && *y + fh > a->y + a->height)
|
||||||
*y = a->y + MAX(0, a->height - fh);
|
*y = a->y + MAX(0, a->height - fh);
|
||||||
|
|
||||||
g_free(a);
|
g_slice_free(Rect, a);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* get where the client should be */
|
/* get where the client should be */
|
||||||
|
@ -2877,7 +2877,7 @@ void client_try_configure(ObClient *self, gint *x, gint *y, gint *w, gint *h,
|
||||||
user = FALSE; /* ignore if the client can't be moved/resized when it
|
user = FALSE; /* ignore if the client can't be moved/resized when it
|
||||||
is maximizing */
|
is maximizing */
|
||||||
|
|
||||||
g_free(a);
|
g_slice_free(Rect, a);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* gets the client's position */
|
/* gets the client's position */
|
||||||
|
@ -4253,7 +4253,7 @@ void client_find_edge_directional(ObClient *self, ObDirection dir,
|
||||||
Rect *area = screen_area(self->desktop, i, NULL);
|
Rect *area = screen_area(self->desktop, i, NULL);
|
||||||
detect_edge(*area, dir, my_head, my_size, my_edge_start,
|
detect_edge(*area, dir, my_head, my_size, my_edge_start,
|
||||||
my_edge_size, dest, near_edge);
|
my_edge_size, dest, near_edge);
|
||||||
g_free(area);
|
g_slice_free(Rect, area);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* search for edges of clients */
|
/* search for edges of clients */
|
||||||
|
@ -4284,7 +4284,7 @@ void client_find_edge_directional(ObClient *self, ObDirection dir,
|
||||||
my_edge_size, dest, near_edge);
|
my_edge_size, dest, near_edge);
|
||||||
}
|
}
|
||||||
|
|
||||||
g_free(a);
|
g_slice_free(Rect, a);
|
||||||
}
|
}
|
||||||
|
|
||||||
void client_find_move_directional(ObClient *self, ObDirection dir,
|
void client_find_move_directional(ObClient *self, ObDirection dir,
|
||||||
|
|
|
@ -150,7 +150,7 @@ static gboolean place_random(ObClient *client, gint *x, gint *y)
|
||||||
else *y = areas[i]->y;
|
else *y = areas[i]->y;
|
||||||
|
|
||||||
for (i = 0; i < screen_num_monitors; ++i)
|
for (i = 0; i < screen_num_monitors; ++i)
|
||||||
g_free(areas[i]);
|
g_slice_free(Rect, areas[i]);
|
||||||
g_free(areas);
|
g_free(areas);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -339,7 +339,7 @@ static gboolean place_nooverlap(ObClient *c, gint *x, gint *y)
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < screen_num_monitors; ++i)
|
for (i = 0; i < screen_num_monitors; ++i)
|
||||||
g_free(areas[i]);
|
g_slice_free(Rect, areas[i]);
|
||||||
g_free(areas);
|
g_free(areas);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -364,6 +364,8 @@ static gboolean place_under_mouse(ObClient *client, gint *x, gint *y)
|
||||||
*y = py - client->area.height / 2 - client->frame->size.top;
|
*y = py - client->area.height / 2 - client->frame->size.top;
|
||||||
*y = MIN(MAX(*y, t), b);
|
*y = MIN(MAX(*y, t), b);
|
||||||
|
|
||||||
|
g_slice_free(Rect, area);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -394,7 +396,7 @@ static gboolean place_per_app_setting(ObClient *client, gint *x, gint *y,
|
||||||
|
|
||||||
/* don't free the first one, it's being set as "screen" */
|
/* don't free the first one, it's being set as "screen" */
|
||||||
for (i = 1; i < screen_num_monitors; ++i)
|
for (i = 1; i < screen_num_monitors; ++i)
|
||||||
g_free(areas[i]);
|
g_slice_free(Rect, areas[i]);
|
||||||
g_free(areas);
|
g_free(areas);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -414,7 +416,7 @@ static gboolean place_per_app_setting(ObClient *client, gint *x, gint *y,
|
||||||
else
|
else
|
||||||
*y = screen->y + settings->position.y.pos;
|
*y = screen->y + settings->position.y.pos;
|
||||||
|
|
||||||
g_free(screen);
|
g_slice_free(Rect, screen);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -460,7 +462,7 @@ static gboolean place_transient_splash(ObClient *client, gint *x, gint *y)
|
||||||
*y = (areas[0]->height - client->frame->area.height) / 2 + areas[0]->y;
|
*y = (areas[0]->height - client->frame->area.height) / 2 + areas[0]->y;
|
||||||
|
|
||||||
for (i = 0; i < screen_num_monitors; ++i)
|
for (i = 0; i < screen_num_monitors; ++i)
|
||||||
g_free(areas[i]);
|
g_slice_free(Rect, areas[i]);
|
||||||
g_free(areas);
|
g_free(areas);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -202,7 +202,7 @@ void resist_move_monitors(ObClient *c, gint resist, gint *x, gint *y)
|
||||||
else if (cb <= pb && b > pb && b < pb + resist)
|
else if (cb <= pb && b > pb && b < pb + resist)
|
||||||
*y = pb - h + 1;
|
*y = pb - h + 1;
|
||||||
|
|
||||||
g_free(area);
|
g_slice_free(Rect, area);
|
||||||
g_free(parea);
|
g_free(parea);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -414,7 +414,7 @@ void resist_size_monitors(ObClient *c, gint resist, gint *w, gint *h,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_free(area);
|
g_slice_free(Rect, area);
|
||||||
g_free(parea);
|
g_free(parea);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1298,11 +1298,14 @@ typedef struct {
|
||||||
} ObScreenStrut;
|
} ObScreenStrut;
|
||||||
|
|
||||||
#define RESET_STRUT_LIST(sl) \
|
#define RESET_STRUT_LIST(sl) \
|
||||||
(g_slist_free(sl), sl = NULL)
|
while (sl) { \
|
||||||
|
g_slice_free(ObScreenStrut, (sl)->data); \
|
||||||
|
sl = g_slist_delete_link(sl, sl); \
|
||||||
|
}
|
||||||
|
|
||||||
#define ADD_STRUT_TO_LIST(sl, d, s) \
|
#define ADD_STRUT_TO_LIST(sl, d, s) \
|
||||||
{ \
|
{ \
|
||||||
ObScreenStrut *ss = g_new(ObScreenStrut, 1); \
|
ObScreenStrut *ss = g_slice_new(ObScreenStrut); \
|
||||||
ss->desktop = d; \
|
ss->desktop = d; \
|
||||||
ss->strut = s; \
|
ss->strut = s; \
|
||||||
sl = g_slist_prepend(sl, ss); \
|
sl = g_slist_prepend(sl, ss); \
|
||||||
|
@ -1436,7 +1439,7 @@ void screen_update_areas(void)
|
||||||
dims[i*4+1] = area->y;
|
dims[i*4+1] = area->y;
|
||||||
dims[i*4+2] = area->width;
|
dims[i*4+2] = area->width;
|
||||||
dims[i*4+3] = area->height;
|
dims[i*4+3] = area->height;
|
||||||
g_free(area);
|
g_slice_free(Rect, area);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* set the legacy workarea hint to the union of all the monitors */
|
/* set the legacy workarea hint to the union of all the monitors */
|
||||||
|
@ -1608,7 +1611,7 @@ Rect* screen_area(guint desktop, guint head, Rect *search)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
a = g_new(Rect, 1);
|
a = g_slice_new(Rect);
|
||||||
a->x = l;
|
a->x = l;
|
||||||
a->y = t;
|
a->y = t;
|
||||||
a->width = r - l + 1;
|
a->width = r - l + 1;
|
||||||
|
|
|
@ -135,6 +135,7 @@ Rect *screen_physical_area_primary(gboolean fixed);
|
||||||
/*! @param head is the number of the head or one of SCREEN_AREA_ALL_MONITORS,
|
/*! @param head is the number of the head or one of SCREEN_AREA_ALL_MONITORS,
|
||||||
SCREEN_AREA_ONE_MONITOR
|
SCREEN_AREA_ONE_MONITOR
|
||||||
@param search NULL or the whole monitor(s)
|
@param search NULL or the whole monitor(s)
|
||||||
|
@return A Rect allocated with g_slice_new()
|
||||||
*/
|
*/
|
||||||
Rect* screen_area(guint desktop, guint head, Rect *search);
|
Rect* screen_area(guint desktop, guint head, Rect *search);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue