text edit: new line processing mechanism [not finished]

This commit is contained in:
2026-07-17 16:43:11 +03:00
parent 84ab8a3777
commit 35c666126e
5 changed files with 151 additions and 35 deletions
+18
View File
@@ -13,6 +13,12 @@ void u_d_arr_ptr_init(d_array_ptr_t *arr, int32_t init_capacity) {
memset(arr->arr, 0, sizeof(void *) * init_capacity);
}
/* TODO: check out the correctness */
void u_d_array_append(d_array_ptr_t *arr, void *el_ptr, size_t el_len) {
void *el = malloc(el_len);
u_d_arr_ptr_add(arr, el, arr->length);
}
void u_d_arr_ptr_add(d_array_ptr_t *arr, void *ptr, int32_t idx) {
if (idx > arr->capacity - 1) {
int32_t new_capacity = idx * 2;
@@ -31,4 +37,16 @@ void u_d_arr_ptr_free(d_array_ptr_t *arr) {
arr->length = 0;
free(arr->arr);
arr->arr = NULL;
}
void u_d_arr_free_cb(d_array_ptr_t *arr, u_d_arr_free_callback *callback) {
for (int i = 0; i < arr->length; i++) {
if (arr->arr[i] != NULL) {
callback(arr->arr[i]);
}
}
arr->capacity = 0;
arr->length = 0;
free(arr->arr);
arr->arr = NULL;
}