From 2c0f62c1226b55b9fb546963e4751bd9c82a245b Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Sun, 4 Aug 2024 01:06:00 -0500 Subject: [PATCH] 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. --- level_1/fl_fss/c/fss/basic.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/level_1/fl_fss/c/fss/basic.c b/level_1/fl_fss/c/fss/basic.c index 7ef47cb..c7c0e92 100644 --- a/level_1/fl_fss/c/fss/basic.c +++ b/level_1/fl_fss/c/fss/basic.c @@ -26,11 +26,7 @@ extern "C" { if (status == F_none_eos) return F_data_not_eos; if (status == F_none_stop) return F_data_not_stop; - status = f_string_ranges_increase(state.step_small, found); - if (F_status_is_error(status)) return status; - const f_number_unsigned_t begin = range->start; - found->array[found->used].start = range->start; for (;; ++range->start) { @@ -53,6 +49,8 @@ extern "C" { if (F_status_is_error(status)) return status; + status = f_string_ranges_increase(state.step_small, found); + if (range->start > begin) { found->array[found->used++].stop = range->start - 1; } -- 1.8.3.1