Krolyxon
Commit c093eae

Branches

Refs →

nsxivc093eae

code-style: use constant length array (#79)

currently the code-base doesn't make use of variable length array
despite being -std=c99. it was irresponsible of me to introduce VLA in
here.

since this function will be called quite often, i did not want to make
calls to malloc and free as they have some overhead.

512 should be sufficient enough and probably is far bigger than any
window title bar can display anyways.
Author
N-R-K
Date
2021-09-22 01:53 +0600
Committer
GitHub · 2021-09-22 01:53 +0600
Parent
9c3310b
Commit
c093eae9712e79cba958ab49457b4f2912fd95d7

+1 −1

1 file changed

  1. M window.c +1 −1
M window.c View
@@ -493,7 +493,7 @@ void win_draw_rect(win_t *win, int x, int y, int w, int h, bool fill, int lw,
493493
494494 void win_set_title(win_t *win, const char *path)
495495 {
496− const unsigned int title_max = strlen(path) + strlen(options->title_prefix) + 1;
496+ enum { title_max = 512 };
497497 char title[title_max];
498498 const char *basename = strrchr(path, '/') + 1;
499499