Implemented termkey_free()

This commit is contained in:
Paul LeoNerd Evans 2008-02-23 20:07:48 +00:00
parent dda9be9110
commit 8f8e96f015
2 changed files with 11 additions and 0 deletions

2
demo.c
View File

@ -46,4 +46,6 @@ int main(int argc, char *argv[]) {
termios.c_lflag = old_lflag; termios.c_lflag = old_lflag;
tcsetattr(0, TCSANOW, &termios); tcsetattr(0, TCSANOW, &termios);
termkey_free(tk);
} }

View File

@ -189,6 +189,15 @@ termkey_t *termkey_new(int fd, int flags)
return termkey_new_full(fd, flags, 256, 50); return termkey_new_full(fd, flags, 256, 50);
} }
void termkey_free(termkey_t *tk)
{
free(tk->buffer); tk->buffer = NULL;
free(tk->keynames); tk->keynames = NULL;
free(tk->csifuncs); tk->csifuncs = NULL;
free(tk);
}
void termkey_setwaittime(termkey_t *tk, int msec) void termkey_setwaittime(termkey_t *tk, int msec)
{ {
tk->waittime = msec; tk->waittime = msec;