summaryrefslogtreecommitdiff
path: root/src/tty_interface.c
diff options
context:
space:
mode:
authorJohn Hawthorn <john@hawthorn.email>2019-12-27 22:26:48 -0800
committerGitHub <noreply@github.com>2019-12-27 22:26:48 -0800
commit25ebdd4f95f024bce2ec5b84f72c30bbd63ed57a (patch)
treeba3ff5313500d3b0078c78e1daadce36460c8a3d /src/tty_interface.c
parentf770d7da17850036df887b2f41a86c38ba255135 (diff)
parent66316266df901eab81ae116c6e0728d10d0214e4 (diff)
Merge pull request #132 from jhawthorn/no_vla
Avoid use of VLA and reduce memory usage in match to O(m)
Diffstat (limited to 'src/tty_interface.c')
-rw-r--r--src/tty_interface.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/tty_interface.c b/src/tty_interface.c
index 225f33a..e87301d 100644
--- a/src/tty_interface.c
+++ b/src/tty_interface.c
@@ -36,8 +36,8 @@ static void draw_match(tty_interface_t *state, const char *choice, int selected)
char *search = state->last_search;
int n = strlen(search);
- size_t positions[n + 1];
- for (int i = 0; i < n + 1; i++)
+ size_t positions[MATCH_MAX_LEN];
+ for (int i = 0; i < n + 1 && i < MATCH_MAX_LEN; i++)
positions[i] = -1;
score_t score = match_positions(search, choice, &positions[0]);