aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPřemysl Janouch <p.janouch@gmail.com>2016-01-01 01:17:56 +0100
committerPřemysl Janouch <p.janouch@gmail.com>2016-01-01 02:00:02 +0100
commit1a73f1f1d777de05d9263cc046d76436d52cc816 (patch)
treef2b4497c6b62feba342b64eb711eed59a72fde45
parent312d0783cf3f68c8e9efdf5a45d10294dd49fdc7 (diff)
downloadxK-1a73f1f1d777de05d9263cc046d76436d52cc816.tar.gz
xK-1a73f1f1d777de05d9263cc046d76436d52cc816.tar.xz
xK-1a73f1f1d777de05d9263cc046d76436d52cc816.zip
degesch: fix a memory leak under libedit
-rw-r--r--degesch.c33
1 files changed, 19 insertions, 14 deletions
diff --git a/degesch.c b/degesch.c
index 4831a3b..59a60a0 100644
--- a/degesch.c
+++ b/degesch.c
@@ -11086,24 +11086,29 @@ on_editline_return (EditLine *editline, int key)
static void
app_editline_init (struct input *self)
{
- static const struct { const char *name; const char *help;
+#define XX(name, help, fn) { name, help, on_editline_ ## fn },
+
+ // el_set() leaks memory in 20150325 and other versions, we need wchar_t
+ static const struct { const wchar_t *name; const wchar_t *help;
unsigned char (*func) (EditLine *, int); } x[] =
{
- { "goto-buffer", "Go to buffer", on_editline_goto_buffer },
- { "previous-buffer", "Previous buffer", on_editline_previous_buffer },
- { "next-buffer", "Next buffer", on_editline_next_buffer },
- { "switch-buffer", "Switch buffer", on_editline_switch_buffer },
- { "display-backlog", "Show backlog", on_editline_display_backlog },
- { "display-full-log", "Show full log", on_editline_display_full_log },
- { "edit-input", "Edit input", on_editline_edit_input },
- { "redraw-screen", "Redraw screen", on_editline_redraw_screen },
- { "insert-attribute", "mIRC formatting", on_editline_insert_attribute },
- { "start-paste-mode", "Bracketed paste", on_editline_start_paste_mode },
- { "send-line", "Send line", on_editline_return },
- { "complete", "Complete word", on_editline_complete },
+ XX( L"goto-buffer", L"Go to buffer", goto_buffer )
+ XX( L"previous-buffer", L"Previous buffer", previous_buffer )
+ XX( L"next-buffer", L"Next buffer", next_buffer )
+ XX( L"switch-buffer", L"Switch buffer", switch_buffer )
+ XX( L"display-backlog", L"Show backlog", display_backlog )
+ XX( L"display-full-log", L"Show full log", display_full_log )
+ XX( L"edit-input", L"Edit input", edit_input )
+ XX( L"redraw-screen", L"Redraw screen", redraw_screen )
+ XX( L"insert-attribute", L"mIRC formatting", insert_attribute )
+ XX( L"start-paste-mode", L"Bracketed paste", start_paste_mode )
+ XX( L"send-line", L"Send line", return )
+ XX( L"complete", L"Complete word", complete )
};
for (size_t i = 0; i < N_ELEMENTS (x); i++)
- el_set (self->editline, EL_ADDFN, x[i].name, x[i].help, x[i].func);
+ el_wset (self->editline, EL_ADDFN, x[i].name, x[i].help, x[i].func);
+
+#undef XX
bind_common_keys (g_ctx);