From c36c12b53aeae9ceecc6e4cccc1f4da72e35f9c1 Mon Sep 17 00:00:00 2001 From: Paul LeoNerd Evans Date: Sun, 10 Feb 2008 20:29:59 +0000 Subject: Implement growing the buffer after input --- termkey.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/termkey.c b/termkey.c index 644629f..2448833 100644 --- a/termkey.c +++ b/termkey.c @@ -640,8 +640,11 @@ termkey_result termkey_waitkey(termkey_t *tk, termkey_key *key) void termkey_pushinput(termkey_t *tk, unsigned char *input, size_t inputlen) { if(tk->buffstart + tk->buffcount + inputlen > tk->buffsize) { - fprintf(stderr, "TODO! Extend input buffer!\n"); - exit(0); + while(tk->buffstart + tk->buffcount + inputlen > tk->buffsize) + tk->buffsize *= 2; + + unsigned char *newbuffer = realloc(tk->buffer, tk->buffsize); + tk->buffer = newbuffer; } // Not strcpy just in case of NUL bytes -- cgit v1.2.3-70-g09d2