Skip to content

Conversation

@spenserblack
Copy link
Owner

This rewrites a large portion of the code to avoid heap allocations. This is a significant rewrite, and may fix/change other behavior as well.

@spenserblack spenserblack linked an issue Nov 22, 2025 that may be closed by this pull request
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors the codebase to eliminate heap allocations by replacing dynamically allocated strings with static buffers. The major architectural change involves converting functions that previously returned char* pointers (requiring malloc/strdup) to void functions that write results into caller-provided fixed-size buffers.

Key changes:

  • API redesigned to use static buffers (char buf[static STATS_VERSION_SIZE]) instead of returning heap-allocated strings
  • Version bumped from 1.1.1 to 2.0.0 (breaking API change)
  • FetchStat struct changed from storing string pointers to function pointers

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
src/version.c Version bumped from 1.1.1 to 2.0.0 to reflect breaking API changes
src/stats.h API redesigned: functions now take buffer parameters instead of returning strings; FetchStat stores function pointers; stats array exposed as extern const
src/stats.c Complete rewrite: all functions modified to write to caller-provided buffers; string extraction logic rewritten for static buffers; unused parameter tracking bug fixed
src/fetchfetch.c Updated to use new API: calls fetcher functions with buffer parameter instead of accessing pre-populated version strings
.git-blame-ignore-revs Added commit hash for this formatting/rewrite to git blame ignore list

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

spenserblack and others added 2 commits November 22, 2025 18:59
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Right boundary was being found for the full version output, not the
left-trimmed version output, which was causing incorrect prefix
detection.
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 10 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

spenserblack and others added 2 commits November 22, 2025 19:26
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@spenserblack spenserblack merged commit 10462f2 into main Nov 23, 2025
1 check passed
@spenserblack spenserblack deleted the bugfix/30/memory-leaks branch November 23, 2025 00:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Reduce heap allocations

2 participants