avoid doing dynamic allocation for bar buffers (#279)
just use a static buffer since the size is constant and doesn't change.
as opposed to using malloc, this also sets the buffer's initial memory
region to 0 by default.
also remove BAR_{L,R}_LEN from nsxiv.h, not needed after commit b4268fbf38
This commit is contained in:
parent
57ff8afe02
commit
364c3d6f01
5
nsxiv.h
5
nsxiv.h
|
@ -366,11 +366,6 @@ spawn_t spawn(const char*, char *const [], unsigned int);
|
||||||
#include <X11/Xft/Xft.h>
|
#include <X11/Xft/Xft.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
enum {
|
|
||||||
BAR_L_LEN = 512,
|
|
||||||
BAR_R_LEN = 64
|
|
||||||
};
|
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
ATOM_WM_DELETE_WINDOW,
|
ATOM_WM_DELETE_WINDOW,
|
||||||
ATOM__NET_WM_NAME,
|
ATOM__NET_WM_NAME,
|
||||||
|
|
18
window.c
18
window.c
|
@ -106,11 +106,13 @@ void win_init(win_t *win)
|
||||||
{
|
{
|
||||||
win_env_t *e;
|
win_env_t *e;
|
||||||
const char *win_bg, *win_fg, *mrk_fg;
|
const char *win_bg, *win_fg, *mrk_fg;
|
||||||
#if HAVE_LIBFONTS
|
|
||||||
const char *bar_fg, *bar_bg, *f;
|
|
||||||
#endif
|
|
||||||
char *res_man;
|
char *res_man;
|
||||||
XrmDatabase db;
|
XrmDatabase db;
|
||||||
|
#if HAVE_LIBFONTS
|
||||||
|
const char *bar_fg, *bar_bg, *f;
|
||||||
|
|
||||||
|
static char lbuf[512 + 3], rbuf[64 + 3];
|
||||||
|
#endif
|
||||||
|
|
||||||
memset(win, 0, sizeof(win_t));
|
memset(win, 0, sizeof(win_t));
|
||||||
|
|
||||||
|
@ -148,13 +150,11 @@ void win_init(win_t *win)
|
||||||
f = win_res(db, RES_CLASS ".bar.font", DEFAULT_FONT);
|
f = win_res(db, RES_CLASS ".bar.font", DEFAULT_FONT);
|
||||||
win_init_font(e, f);
|
win_init_font(e, f);
|
||||||
|
|
||||||
win->bar.l.size = BAR_L_LEN;
|
win->bar.l.buf = lbuf;
|
||||||
win->bar.r.size = BAR_R_LEN;
|
win->bar.r.buf = rbuf;
|
||||||
/* 3 padding bytes needed by utf8_decode */
|
/* 3 padding bytes needed by utf8_decode */
|
||||||
win->bar.l.buf = emalloc(win->bar.l.size + 3);
|
win->bar.l.size = sizeof(lbuf) - 3;
|
||||||
win->bar.l.buf[0] = '\0';
|
win->bar.r.size = sizeof(rbuf) - 3;
|
||||||
win->bar.r.buf = emalloc(win->bar.r.size + 3);
|
|
||||||
win->bar.r.buf[0] = '\0';
|
|
||||||
win->bar.h = options->hide_bar ? 0 : barheight;
|
win->bar.h = options->hide_bar ? 0 : barheight;
|
||||||
win->bar.top = TOP_STATUSBAR;
|
win->bar.top = TOP_STATUSBAR;
|
||||||
#endif /* HAVE_LIBFONTS */
|
#endif /* HAVE_LIBFONTS */
|
||||||
|
|
Loading…
Reference in a new issue