From cb6c7d73322f62354a979a5338b41a5a297c5795 Mon Sep 17 00:00:00 2001 From: okan Date: Tue, 4 Oct 2016 15:52:32 +0000 Subject: Calculate client nameqlen in client_setname(), the only place it's needed/used. --- client.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'client.c') diff --git a/client.c b/client.c index 9268d05..9644a98 100644 --- a/client.c +++ b/client.c @@ -15,7 +15,7 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * - * $OpenBSD: client.c,v 1.227 2016/10/03 14:42:34 okan Exp $ + * $OpenBSD: client.c,v 1.228 2016/10/04 15:52:32 okan Exp $ */ #include @@ -605,6 +605,7 @@ client_setname(struct client_ctx *cc) { struct winname *wn; char *newname; + int i = 0; if (!xu_getstrprop(cc->win, ewmh[_NET_WM_NAME], &newname)) if (!xu_getstrprop(cc->win, XA_WM_NAME, &newname)) @@ -621,19 +622,19 @@ client_setname(struct client_ctx *cc) wn = xmalloc(sizeof(*wn)); wn->name = newname; TAILQ_INSERT_TAIL(&cc->nameq, wn, entry); - cc->nameqlen++; match: cc->name = wn->name; - /* Now, do some garbage collection. */ - if (cc->nameqlen > CLIENT_MAXNAMEQLEN) { - if ((wn = TAILQ_FIRST(&cc->nameq)) == NULL) - errx(1, "client_setname: window name queue empty"); + /* Do some garbage collection. */ + TAILQ_FOREACH(wn, &cc->nameq, entry) + i++; + if (i > Conf.nameqlen) { + wn = TAILQ_FIRST(&cc->nameq); TAILQ_REMOVE(&cc->nameq, wn, entry); free(wn->name); free(wn); - cc->nameqlen--; + i--; } } -- cgit v1.2.3-2-gb3c3