Fixed one memleak, investigating the next one
diff --git a/linenoise.c b/linenoise.c
index f7f2159..6aabe17 100644
--- a/linenoise.c
+++ b/linenoise.c
@@ -80,13 +80,14 @@
#include <sys/ioctl.h>
#include <unistd.h>
+#define LINENOISE_DEFAULT_HISTORY_MAX_LEN 100
#define LINENOISE_MAX_LINE 4096
static char *unsupported_term[] = {"dumb","cons25",NULL};
static struct termios orig_termios; /* in order to restore at exit */
static int rawmode = 0; /* for atexit() function to check if restore is needed*/
static int atexit_registered = 0; /* register atexit just 1 time */
-static int history_max_len = 100;
+static int history_max_len = LINENOISE_DEFAULT_HISTORY_MAX_LEN;
static int history_len = 0;
char **history = NULL;
@@ -403,6 +404,7 @@ int linenoiseHistoryAdd(const char *line) {
linecopy = strdup(line);
if (!linecopy) return 0;
if (history_len == history_max_len) {
+ free(history[0]);
memmove(history,history+1,sizeof(char*)*(history_max_len-1));
history_len--;
}