From 61076a280bbad412abf0843eff186d8df773f5b6 Mon Sep 17 00:00:00 2001 From: nicm Date: Thu, 20 Apr 2017 09:39:07 +0000 Subject: [PATCH] There is no real need for window_printable_flags to allocate, make it return a buffer from the stack. --- usr.bin/tmux/format.c | 9 ++------- usr.bin/tmux/tmux.h | 4 ++-- usr.bin/tmux/window.c | 10 +++++----- 3 files changed, 9 insertions(+), 14 deletions(-) diff --git a/usr.bin/tmux/format.c b/usr.bin/tmux/format.c index 00875270456..052d481ef08 100644 --- a/usr.bin/tmux/format.c +++ b/usr.bin/tmux/format.c @@ -1,4 +1,4 @@ -/* $OpenBSD: format.c,v 1.127 2017/04/20 09:20:22 nicm Exp $ */ +/* $OpenBSD: format.c,v 1.128 2017/04/20 09:39:07 nicm Exp $ */ /* * Copyright (c) 2011 Nicholas Marriott @@ -1237,17 +1237,14 @@ format_defaults_winlink(struct format_tree *ft, struct session *s, struct winlink *wl) { struct window *w = wl->window; - char *flags; if (ft->w == NULL) ft->w = wl->window; - flags = window_printable_flags(s, wl); - format_defaults_window(ft, w); format_add(ft, "window_index", "%d", wl->idx); - format_add(ft, "window_flags", "%s", flags); + format_add(ft, "window_flags", "%s", window_printable_flags(s, wl)); format_add(ft, "window_active", "%d", wl == s->curw); format_add(ft, "window_bell_flag", "%d", @@ -1259,8 +1256,6 @@ format_defaults_winlink(struct format_tree *ft, struct session *s, format_add(ft, "window_last_flag", "%d", !!(wl == TAILQ_FIRST(&s->lastw))); format_add(ft, "window_linked", "%d", session_is_linked(s, wl->window)); - - free(flags); } /* Set default format keys for a window pane. */ diff --git a/usr.bin/tmux/tmux.h b/usr.bin/tmux/tmux.h index e28e52cc2db..c74badd0c63 100644 --- a/usr.bin/tmux/tmux.h +++ b/usr.bin/tmux/tmux.h @@ -1,4 +1,4 @@ -/* $OpenBSD: tmux.h,v 1.741 2017/04/20 09:20:22 nicm Exp $ */ +/* $OpenBSD: tmux.h,v 1.742 2017/04/20 09:39:07 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -2120,7 +2120,7 @@ int window_pane_outside(struct window_pane *); int window_pane_visible(struct window_pane *); char *window_pane_search(struct window_pane *, const char *, u_int *); -char *window_printable_flags(struct session *, struct winlink *); +const char *window_printable_flags(struct session *, struct winlink *); struct window_pane *window_pane_find_up(struct window_pane *); struct window_pane *window_pane_find_down(struct window_pane *); struct window_pane *window_pane_find_left(struct window_pane *); diff --git a/usr.bin/tmux/window.c b/usr.bin/tmux/window.c index b4ccd5dac49..1e9bdd422a8 100644 --- a/usr.bin/tmux/window.c +++ b/usr.bin/tmux/window.c @@ -1,4 +1,4 @@ -/* $OpenBSD: window.c,v 1.187 2017/03/21 09:49:10 nicm Exp $ */ +/* $OpenBSD: window.c,v 1.188 2017/04/20 09:39:07 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -710,11 +710,11 @@ window_destroy_panes(struct window *w) } /* Retuns the printable flags on a window, empty string if no flags set. */ -char * +const char * window_printable_flags(struct session *s, struct winlink *wl) { - char flags[32]; - int pos; + static char flags[32]; + int pos; pos = 0; if (wl->flags & WINLINK_ACTIVITY) @@ -732,7 +732,7 @@ window_printable_flags(struct session *s, struct winlink *wl) if (wl->window->flags & WINDOW_ZOOMED) flags[pos++] = 'Z'; flags[pos] = '\0'; - return (xstrdup(flags)); + return (flags); } struct window_pane * -- 2.20.1