-
Notifications
You must be signed in to change notification settings - Fork 3
Remove heap allocations #31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this 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)
FetchStatstruct 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.
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.
There was a problem hiding this 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.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
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.