fzy

terminal fuzzy finder picker

git clone https://9o.is/git/fzy.git

commit 2100ed06b19189a928d250cecf273d310388411c
parent a19b0f263bec7cb7916b1d81d28c9cdb1bcf047d
Author: John Hawthorn <john.hawthorn@gmail.com>
Date:   Tue, 16 Sep 2014 19:05:26 -0700

Abort on allocation errors

Diffstat:
Mchoices.c | 6++++++
1 file changed, 6 insertions(+), 0 deletions(-)

diff --git a/choices.c b/choices.c @@ -1,5 +1,6 @@ #define _GNU_SOURCE #include <stdlib.h> +#include <stdio.h> #include "choices.h" #include "match.h" @@ -23,6 +24,11 @@ static void choices_resize(choices_t *c, int new_capacity){ c->scores = realloc(c->scores, new_capacity * sizeof(double)); c->sorted = realloc(c->sorted, new_capacity * sizeof(size_t)); + if(!c->strings || !c->scores || !c->sorted){ + fprintf(stderr, "Error: Can't allocate memory\n"); + abort(); + } + for(int i = c->capacity; i < new_capacity; i++){ c->strings[i] = NULL; }