From: Kevin Day Date: Sun, 4 Aug 2024 06:07:22 +0000 (-0500) Subject: Update: Reduce memory usage by fl_fss_basic_content_read() in some circumstances. X-Git-Url: https://git.kevux.org/?a=commitdiff_plain;h=8295c3c2eb074cb0d306b900d73d45ba56212b87;p=fll Update: Reduce memory usage by fl_fss_basic_content_read() in some circumstances. The fl_fss_basic_content_read() is simple enough that the allocation of the found array is only needed on success. --- diff --git a/level_1/fl_fss/c/fss/basic.c b/level_1/fl_fss/c/fss/basic.c index c6a4700..a8e2c45 100644 --- a/level_1/fl_fss/c/fss/basic.c +++ b/level_1/fl_fss/c/fss/basic.c @@ -40,11 +40,7 @@ extern "C" { return; } - state->status = f_memory_array_increase(state->step_small, sizeof(f_range_t), (void **) &found->array, &found->used, &found->size); - if (F_status_is_error(state->status)) return; - const f_number_unsigned_t begin = range->start; - found->array[found->used].start = range->start; for (;; ++range->start) { @@ -62,7 +58,11 @@ extern "C" { if (F_status_is_error(state->status)) return; + state->status = f_memory_array_increase(found->size ? found->size == 1 ? 4 : state->step_small : 1, sizeof(f_range_t), (void **) &found->array, &found->used, &found->size); + if (F_status_is_error(state->status)) return; + if (range->start > begin) { + found->array[found->used].start = begin; found->array[found->used++].stop = range->start - 1; } else {