diff options
author | Christian Göttsche <cgzones@googlemail.com> | 2020-12-19 23:05:07 +0100 |
---|---|---|
committer | Christian Göttsche <cgzones@googlemail.com> | 2020-12-20 17:01:50 +0100 |
commit | 358d20687f6913f151f3943e1d8655ce71457f6d (patch) | |
tree | b2f682688d1824f67af82cf436f069a70911777b /CommandScreen.c | |
parent | e3862aa67e37ecef0eb8f82ba1f4a710ffac9c02 (diff) |
Use variable-length-array instead of small dynamic allocation
Diffstat (limited to 'CommandScreen.c')
-rw-r--r-- | CommandScreen.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/CommandScreen.c b/CommandScreen.c index d3428290..56b752d6 100644 --- a/CommandScreen.c +++ b/CommandScreen.c @@ -17,9 +17,10 @@ static void CommandScreen_scan(InfoScreen* this) { Panel_prune(panel); const char* p = Process_getCommand(this->process); - char* line = xMalloc(COLS + 1); + char line[COLS + 1]; int line_offset = 0, last_spc = -1, len; for (; *p != '\0'; p++, line_offset++) { + assert(line_offset >= 0 && (size_t)line_offset < sizeof(line)); line[line_offset] = *p; if (*p == ' ') { last_spc = line_offset; @@ -41,7 +42,6 @@ static void CommandScreen_scan(InfoScreen* this) { InfoScreen_addLine(this, line); } - free(line); Panel_setSelected(panel, idx); } |