diff options
author | Thomas Roessler <roessler@does-not-exist.org> | 1999-07-26 14:04:03 +0000 |
---|---|---|
committer | Thomas Roessler <roessler@does-not-exist.org> | 1999-07-26 14:04:03 +0000 |
commit | ceac07b8db1c52a2bcfeb6762dc9d891538b9e69 (patch) | |
tree | e6500799084c2abb912ad00983338f54d42a0d34 /curs_lib.c | |
parent | a977243ab92138c45b173fb3dcf8de52be0221ef (diff) |
Dynamically allocate the unget buffer. Fixes Debian bug #41042.
From Gero Treuner.
Diffstat (limited to 'curs_lib.c')
-rw-r--r-- | curs_lib.c | 15 |
1 files changed, 7 insertions, 8 deletions
@@ -34,9 +34,9 @@ * is impossible to unget function keys in SLang, so roll our own input * buffering routines. */ -static short UngetCount = 0; -#define UngetBufLen 128 -static event_t KeyEvent[UngetBufLen] = { {0,0} }; +static size_t UngetCount = 0; +static size_t UngetBufLen = 0; +static event_t *KeyEvent; void mutt_refresh (void) { @@ -372,9 +372,6 @@ int _mutt_enter_fname (const char *prompt, char *buf, size_t blen, int *redraw, return 0; } -/* FOO - this could be made more efficient by allocating/deallocating memory - * instead of using a fixed array - */ void mutt_ungetch (int ch, int op) { event_t tmp; @@ -382,8 +379,10 @@ void mutt_ungetch (int ch, int op) tmp.ch = ch; tmp.op = op; - if (UngetCount < UngetBufLen) /* make sure not to overflow */ - KeyEvent[UngetCount++] = tmp; + if (UngetCount >= UngetBufLen) + safe_realloc ((void **) &KeyEvent, (UngetBufLen += 128) * sizeof(event_t)); + + KeyEvent[UngetCount++] = tmp; } void mutt_flushinp (void) |