mirror of
https://github.com/troglobit/editline.git
synced 2025-05-06 04:21:24 +08:00
rl_unintialize(): New function, free all memory after use
Free all allocated internal memory and reset variables so rl_initialize() or readline() may be called again later. Signed-off-by: Claus Fischer <claus.fischer@clausfischer.com> Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
parent
ed87f37409
commit
317b43e488
@ -82,6 +82,7 @@ extern int el_hist_size; /* size of history scrollback buffer, default:
|
|||||||
|
|
||||||
extern void rl_initialize(void);
|
extern void rl_initialize(void);
|
||||||
extern void rl_reset_terminal(const char *terminal_name);
|
extern void rl_reset_terminal(const char *terminal_name);
|
||||||
|
extern void rl_uninitialize(void);
|
||||||
|
|
||||||
void rl_save_prompt(void);
|
void rl_save_prompt(void);
|
||||||
void rl_restore_prompt(void);
|
void rl_restore_prompt(void);
|
||||||
|
@ -1145,6 +1145,30 @@ void rl_initialize(void)
|
|||||||
if (el_outfd < 0) el_outfd = EL_STDOUT;
|
if (el_outfd < 0) el_outfd = EL_STDOUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void rl_uninitialize(void)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
/* Uninitialize the history */
|
||||||
|
if (H.Lines) {
|
||||||
|
for (i = 0; i < el_hist_size; i++) {
|
||||||
|
if (H.Lines[i])
|
||||||
|
free(H.Lines[i]);
|
||||||
|
H.Lines[i] = 0;
|
||||||
|
}
|
||||||
|
free(H.Lines);
|
||||||
|
H.Lines = 0;
|
||||||
|
}
|
||||||
|
H.Size = 0;
|
||||||
|
H.Pos = 0;
|
||||||
|
|
||||||
|
/* Uninitialize the line buffer */
|
||||||
|
if (rl_line_buffer)
|
||||||
|
free(rl_line_buffer);
|
||||||
|
rl_line_buffer = NULL;
|
||||||
|
Length = 0;
|
||||||
|
}
|
||||||
|
|
||||||
static const char *rl_saved_prompt = NULL;
|
static const char *rl_saved_prompt = NULL;
|
||||||
void rl_save_prompt(void)
|
void rl_save_prompt(void)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user