From 8f8e96f015efa9541f6584ff5d15fe3f01a32b28 Mon Sep 17 00:00:00 2001 From: Paul LeoNerd Evans Date: Sat, 23 Feb 2008 20:07:48 +0000 Subject: Implemented termkey_free() --- demo.c | 2 ++ termkey.c | 9 +++++++++ 2 files changed, 11 insertions(+) diff --git a/demo.c b/demo.c index 4a96b64..df1627a 100644 --- a/demo.c +++ b/demo.c @@ -46,4 +46,6 @@ int main(int argc, char *argv[]) { termios.c_lflag = old_lflag; tcsetattr(0, TCSANOW, &termios); + + termkey_free(tk); } diff --git a/termkey.c b/termkey.c index 411d958..2830f01 100644 --- a/termkey.c +++ b/termkey.c @@ -189,6 +189,15 @@ termkey_t *termkey_new(int fd, int flags) 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) { tk->waittime = msec; -- cgit v1.2.3-70-g09d2