diff options
author | pommicket <pommicket@gmail.com> | 2023-07-19 11:46:28 -0400 |
---|---|---|
committer | pommicket <pommicket@gmail.com> | 2023-07-19 19:03:22 -0400 |
commit | 4143734747b7b544daecdf1b8676838362c6cb59 (patch) | |
tree | e7c879967027f47b957c35e551b3e971a6aab924 | |
parent | e5dc92fcd600b15977cad7c81de7b8c1cd11fb87 (diff) |
fix memory leaks (not really leaky)
-rw-r--r-- | lsp-write.c | 7 | ||||
-rw-r--r-- | lsp.c | 1 | ||||
-rw-r--r-- | lsp.h | 2 | ||||
-rw-r--r-- | main.c | 1 | ||||
-rw-r--r-- | syntax.c | 8 | ||||
-rw-r--r-- | ted.h | 2 |
6 files changed, 21 insertions, 0 deletions
diff --git a/lsp-write.c b/lsp-write.c index 830c0ab..df695a6 100644 --- a/lsp-write.c +++ b/lsp-write.c @@ -680,3 +680,10 @@ void write_message(LSP *lsp, LSPMessage *message) { } #undef write_bool + +void lsp_write_quit(void) { + arr_foreach_ptr(language_ids, LanguageId, lid) { + free(lid->identifier); + } + arr_clear(language_ids); +} @@ -747,4 +747,5 @@ void lsp_quit(void) { SDL_DestroyMutex(request_id_mutex); request_id_mutex = NULL; } + lsp_write_quit(); } @@ -755,6 +755,8 @@ char *json_string_get_alloc(const JSON *json, JSONString string); void json_debug_print(const JSON *json); size_t json_escape_to(char *out, size_t out_sz, const char *in); char *json_escape(const char *str); +/// free resources used by lsp-write.c +void lsp_write_quit(void); /// print server-to-client communication #define LSP_SHOW_S2C 0 @@ -1188,6 +1188,7 @@ int main(int argc, char **argv) { ted->lsps[i] = NULL; } lsp_quit(); + syntax_quit(); arr_foreach_ptr(ted->shell_history, char *, cmd) { free(*cmd); @@ -2214,3 +2214,11 @@ void syntax_register_language(const LanguageInfo *info) { lsp_register_language(info->id, info->lsp_identifier); } + +void syntax_quit(void) { + arr_foreach_ptr(language_names, LanguageName, lname) { + free(lname->name); + } + arr_clear(language_names); + arr_clear(syntax_highlighters); +} @@ -1603,6 +1603,8 @@ bool syntax_is_opening_bracket(Language lang, char32_t c); /// To highlight multiple lines, start out with a zeroed SyntaxState, and pass a pointer to it each time. /// You can set char_types to NULL if you just want to advance the state, and don't care about the character types. void syntax_highlight(SyntaxState *state, Language lang, const char32_t *line, u32 line_len, SyntaxCharType *char_types); +/// free up resources used by syntax.c +void syntax_quit(void); // === tags.c === void tags_generate(Ted *ted, bool run_in_build_window); |