diff --git a/TODO.md b/TODO.md index 13d26e1..c1ca79e 100644 --- a/TODO.md +++ b/TODO.md @@ -18,7 +18,7 @@ - [ ] Documentation ## Bugs: -- [ ] Sometimes segfaults while navigating through modal menu +- [x] Sometimes segfaults while navigating through modal menu ## Features: - [x] Search files diff --git a/src/utils/d_array.c b/src/utils/d_array.c index 8a675c9..f0fba1d 100644 --- a/src/utils/d_array.c +++ b/src/utils/d_array.c @@ -10,12 +10,12 @@ void u_d_arr_ptr_init(d_array_ptr_t *arr, int32_t init_capacity) { arr->arr = malloc(sizeof(void *) * init_capacity); arr->fist_el = NULL; arr->last_el = NULL; - memset(arr->arr, 0, init_capacity); + memset(arr->arr, 0, sizeof(void *) * init_capacity); } void u_d_arr_ptr_add(d_array_ptr_t *arr, void *ptr, int32_t idx) { - int32_t new_capacity = idx * 2; if (idx > arr->capacity - 1) { + int32_t new_capacity = idx * 2; arr->arr = realloc(arr->arr, new_capacity); memset(arr->arr+arr->capacity, 0, arr->capacity - new_capacity); arr->capacity = new_capacity;