There is a known memory leak in libedit2 library, when el_set()
function is called with EL_ADDFN parameter. It has been known
by the library author Christos Zoulas from the very beginning.
The existence of the leak is already mentioned in the source code of
the library:
https://salsa.debian.org/debian/libedit/-/blob/master/src/eln.c#L226
The leak exists since the following commit to the library:
http://cvsweb.netbsd.org/bsdweb.cgi/src/lib/libedit/eln.c#rev1.4
There are hints that el_wset() doesn't suffer the same issue, so some
prjects are moving to wide charecters in order to avoid this memory leak.
https://reviews.llvm.org/rGc11e249bfdf406dc609048ca88af406007426630
[ LLDB is leaking memory in Editline.cpp on MacOSX. ]
We are keeping Knot code as is for now.
el_set(el, EL_SIGNAL, 1);
el_source(el, NULL);
+ // Warning: these two el_sets()'s always leak -- in libedit2 library!
+ // For more details see this commit's message.
el_set(el, EL_ADDFN, PROGRAM_NAME"-complete",
"Perform "PROGRAM_NAME" completion.", complete);
el_set(el, EL_BIND, "^I", PROGRAM_NAME"-complete", NULL);