diff --git a/src/main.c b/src/main.c index ccec6091..2aae9bfb 100644 --- a/src/main.c +++ b/src/main.c @@ -289,10 +289,11 @@ static bool isCmd(char* s, char** e, const char* cmd) { void hint_replxx(const char* inp, replxx_hints* res, int* dist, ReplxxColor* c, void* data) { completion_impl(inp, res, true, dist); } - static NOINLINE char* malloc_B(B x) { // toCStr but allocated by malloc + static NOINLINE char* malloc_B(B x) { // toCStr but allocated by malloc; frees x u64 len1 = utf8lenB(x); char* s1 = malloc(len1+1); toUTF8(x, s1); + decG(x); s1[len1] = '\0'; return s1; } @@ -305,7 +306,7 @@ static bool isCmd(char* s, char** e, const char* cmd) { replxx_get_state(global_replxx, &st); return (TmpState){.s = utf8Decode0(st.text), .pos = st.cursorPosition}; } - static NOINLINE void setState(TmpState s) { + static NOINLINE void setState(TmpState s) { // frees s.s char* r = malloc_B(s.s); ReplxxState st = (ReplxxState){.text = r, .cursorPosition = s.pos}; replxx_set_state(global_replxx, &st); @@ -428,7 +429,9 @@ static bool isCmd(char* s, char** e, const char* cmd) { char* s = toCStr(ln); char* e; if (isCmd(s, &e, "theme=" )) cfg_theme = e[0]-'0'; else if (isCmd(s, &e, "keyboard=")) cfg_enableKeyboard = e[0]-'0'; + freeCStr(s); } + decG(lns); cfg_set_theme(cfg_theme, false); cfg_set_keyboard(cfg_enableKeyboard, false); }