# HG changeset patch # User Paper # Date 1703800044 18000 # Node ID 7137fbac0b85c1c1f6979f550abb00142c244e75 # Parent a6ab6d9c0daca993cbafaf449e5573d8df5b61ca edl: expose EDL_reallocate() API to allow resizing the array diff -r a6ab6d9c0dac -r 7137fbac0b85 include/edl.h --- a/include/edl.h Mon Dec 25 16:26:46 2023 -0500 +++ b/include/edl.h Thu Dec 28 16:47:24 2023 -0500 @@ -54,6 +54,7 @@ } EDL; EDL EDL_parse(const char* text, size_t length); +int EDL_reallocate(EDL* edl, size_t new_capacity); char* EDL_dump(EDL edl); void EDL_free(EDL edl); diff -r a6ab6d9c0dac -r 7137fbac0b85 src/edl.c --- a/src/edl.c Mon Dec 25 16:26:46 2023 -0500 +++ b/src/edl.c Thu Dec 28 16:47:24 2023 -0500 @@ -144,7 +144,7 @@ /* memory management routines */ -static int EDL_internal_reallocate(EDL* input, size_t new_capacity) { +int EDL_reallocate(EDL* input, size_t new_capacity) { input->arr = realloc(input->arr, new_capacity * sizeof(EDL_line)); if (!input->arr) return 0; @@ -160,7 +160,7 @@ /* the important function */ EDL EDL_parse(const char* data, size_t length) { EDL edl = {0}; - if (!EDL_internal_reallocate(&edl, 16)) + if (!EDL_reallocate(&edl, 16)) return edl; size_t order_size = 0; @@ -282,10 +282,10 @@ break; if (++edl.size >= edl.capacity) - EDL_internal_reallocate(&edl, edl.capacity * 2); + EDL_reallocate(&edl, edl.capacity * 2); } - EDL_internal_reallocate(&edl, edl.size); + EDL_reallocate(&edl, edl.size); free(order);