degesch: fix a memory leak under libedit

This commit is contained in:
Přemysl Eric Janouch 2016-01-01 01:17:56 +01:00
parent 312d0783cf
commit 1a73f1f1d7

View File

@ -11086,24 +11086,29 @@ on_editline_return (EditLine *editline, int key)
static void static void
app_editline_init (struct input *self) 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[] = unsigned char (*func) (EditLine *, int); } x[] =
{ {
{ "goto-buffer", "Go to buffer", on_editline_goto_buffer }, XX( L"goto-buffer", L"Go to buffer", goto_buffer )
{ "previous-buffer", "Previous buffer", on_editline_previous_buffer }, XX( L"previous-buffer", L"Previous buffer", previous_buffer )
{ "next-buffer", "Next buffer", on_editline_next_buffer }, XX( L"next-buffer", L"Next buffer", next_buffer )
{ "switch-buffer", "Switch buffer", on_editline_switch_buffer }, XX( L"switch-buffer", L"Switch buffer", switch_buffer )
{ "display-backlog", "Show backlog", on_editline_display_backlog }, XX( L"display-backlog", L"Show backlog", display_backlog )
{ "display-full-log", "Show full log", on_editline_display_full_log }, XX( L"display-full-log", L"Show full log", display_full_log )
{ "edit-input", "Edit input", on_editline_edit_input }, XX( L"edit-input", L"Edit input", edit_input )
{ "redraw-screen", "Redraw screen", on_editline_redraw_screen }, XX( L"redraw-screen", L"Redraw screen", redraw_screen )
{ "insert-attribute", "mIRC formatting", on_editline_insert_attribute }, XX( L"insert-attribute", L"mIRC formatting", insert_attribute )
{ "start-paste-mode", "Bracketed paste", on_editline_start_paste_mode }, XX( L"start-paste-mode", L"Bracketed paste", start_paste_mode )
{ "send-line", "Send line", on_editline_return }, XX( L"send-line", L"Send line", return )
{ "complete", "Complete word", on_editline_complete }, XX( L"complete", L"Complete word", complete )
}; };
for (size_t i = 0; i < N_ELEMENTS (x); i++) 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); bind_common_keys (g_ctx);