From eb3b13145dcc68c93cf50ace7b8b3c71fb7a09df Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Sat, 8 Sep 2012 21:13:56 -0500 Subject: [PATCH] avoid allocating a new win struct if possible --- src/compton.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/compton.c b/src/compton.c index 0211748..b72dc59 100644 --- a/src/compton.c +++ b/src/compton.c @@ -1573,16 +1573,15 @@ set_opacity(Display *dpy, win *w, unsigned long opacity) { static void add_win(Display *dpy, Window id, Window prev, Bool override_redirect) { + if (find_win(dpy, id)) { + return; + } + win *new = malloc(sizeof(win)); win **p; if (!new) return; - if (find_win(dpy, id)) { - free(new); - return; - } - if (prev) { for (p = &list; *p; p = &(*p)->next) { if ((*p)->id == prev && !(*p)->destroyed)