linenoiseFree() API introduced.

This commit is contained in:
antirez
2016-04-12 18:08:33 +02:00
parent 12a8680d8a
commit ae5f793ec0
2 changed files with 9 additions and 0 deletions

View File

@@ -1050,6 +1050,14 @@ char *linenoise(const char *prompt) {
}
}
/* This is just a wrapper the user may want to call in order to make sure
* the linenoise returned buffer is freed with the same allocator it was
* created with. Useful when the main program is using an alternative
* allocator. */
void linenoiseFree(void *ptr) {
free(ptr);
}
/* ================================ History ================================= */
/* Free the history, but does not reset it. Only used when we have to

View File

@@ -57,6 +57,7 @@ void linenoiseSetFreeHintsCallback(linenoiseFreeHintsCallback *);
void linenoiseAddCompletion(linenoiseCompletions *, const char *);
char *linenoise(const char *prompt);
void linenoiseFree(void *ptr);
int linenoiseHistoryAdd(const char *line);
int linenoiseHistorySetMaxLen(int len);
int linenoiseHistorySave(const char *filename);