diff options
| author | Paul Buetow <paul@buetow.org> | 2026-04-13 08:46:43 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-04-13 08:46:43 +0300 |
| commit | 74ae0b479e6f4111ef5f2c93b8099f9149c98328 (patch) | |
| tree | 980660820c6677d8c00f8ca61a2c7d9abc250b61 /src/c/fastforge_logic.c | |
| parent | f766431996acd0e15ea913d6f7f38cb9580f9831 (diff) | |
p2: remove silent streak recompute truncation
Diffstat (limited to 'src/c/fastforge_logic.c')
| -rw-r--r-- | src/c/fastforge_logic.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/c/fastforge_logic.c b/src/c/fastforge_logic.c index 4015ec6..8a66804 100644 --- a/src/c/fastforge_logic.c +++ b/src/c/fastforge_logic.c @@ -128,10 +128,14 @@ void fastforge_streak_recompute(const FastEntry *entries, int count, time_t now, return; } - time_t completion_days[MAX_FASTS]; + size_t completion_capacity = (size_t)count; + time_t *completion_days = malloc(completion_capacity * sizeof(*completion_days)); + if (!completion_days) { + return; + } int completion_day_count = 0; - for (int i = 0; i < count && completion_day_count < MAX_FASTS; i++) { + for (int i = 0; i < count; i++) { const FastEntry *entry = &entries[i]; time_t duration = entry_duration_seconds(entry); if (duration <= 0 || entry->end_time <= 0) { @@ -151,6 +155,7 @@ void fastforge_streak_recompute(const FastEntry *entries, int count, time_t now, } if (completion_day_count <= 0) { + free(completion_days); return; } @@ -188,6 +193,7 @@ void fastforge_streak_recompute(const FastEntry *entries, int count, time_t now, out->current_streak = run_length; } out->longest_streak = longest; + free(completion_days); } bool running_fast_is_at_target(const FastEntry *entry, time_t now) { |
