avoid allocating a new win struct if possible
This commit is contained in:
parent
02e2deea54
commit
eb3b13145d
|
@ -1573,16 +1573,15 @@ set_opacity(Display *dpy, win *w, unsigned long opacity) {
|
||||||
|
|
||||||
static void
|
static void
|
||||||
add_win(Display *dpy, Window id, Window prev, Bool override_redirect) {
|
add_win(Display *dpy, Window id, Window prev, Bool override_redirect) {
|
||||||
|
if (find_win(dpy, id)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
win *new = malloc(sizeof(win));
|
win *new = malloc(sizeof(win));
|
||||||
win **p;
|
win **p;
|
||||||
|
|
||||||
if (!new) return;
|
if (!new) return;
|
||||||
|
|
||||||
if (find_win(dpy, id)) {
|
|
||||||
free(new);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (prev) {
|
if (prev) {
|
||||||
for (p = &list; *p; p = &(*p)->next) {
|
for (p = &list; *p; p = &(*p)->next) {
|
||||||
if ((*p)->id == prev && !(*p)->destroyed)
|
if ((*p)->id == prev && !(*p)->destroyed)
|
||||||
|
|
Loading…
Reference in New Issue