diff options
author | Paul LeoNerd Evans <leonerd@leonerd.org.uk> | 2008-02-10 20:29:59 +0000 |
---|---|---|
committer | Paul LeoNerd Evans <leonerd@leonerd.org.uk> | 2008-02-10 20:29:59 +0000 |
commit | c36c12b53aeae9ceecc6e4cccc1f4da72e35f9c1 (patch) | |
tree | 736852b98df887b51af000dc1dd640371bc5a3e9 | |
parent | 53b0d0aca9d87361f6add5c1ff8380b8101ffceb (diff) | |
download | termo-c36c12b53aeae9ceecc6e4cccc1f4da72e35f9c1.tar.gz termo-c36c12b53aeae9ceecc6e4cccc1f4da72e35f9c1.tar.xz termo-c36c12b53aeae9ceecc6e4cccc1f4da72e35f9c1.zip |
Implement growing the buffer after input
-rw-r--r-- | termkey.c | 7 |
1 files changed, 5 insertions, 2 deletions
@@ -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 |