fix: Sometimes segfaults while navigating through modal menu

This commit is contained in:
2026-05-14 17:43:53 +03:00
parent cdeb497c72
commit b5ce749fbf
2 changed files with 3 additions and 3 deletions
+1 -1
View File
@@ -18,7 +18,7 @@
- [ ] Documentation - [ ] Documentation
## Bugs: ## Bugs:
- [ ] Sometimes segfaults while navigating through modal menu - [x] Sometimes segfaults while navigating through modal menu
## Features: ## Features:
- [x] Search files - [x] Search files
+2 -2
View File
@@ -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->arr = malloc(sizeof(void *) * init_capacity);
arr->fist_el = NULL; arr->fist_el = NULL;
arr->last_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) { 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) { if (idx > arr->capacity - 1) {
int32_t new_capacity = idx * 2;
arr->arr = realloc(arr->arr, new_capacity); arr->arr = realloc(arr->arr, new_capacity);
memset(arr->arr+arr->capacity, 0, arr->capacity - new_capacity); memset(arr->arr+arr->capacity, 0, arr->capacity - new_capacity);
arr->capacity = new_capacity; arr->capacity = new_capacity;