6
8
Fork
You've already forked slashtmp
1

Remove free functions in end of files #1

Closed
Gnu1 wants to merge 1 commit from Gnu1/slashtmp:remove_extra_free into master
pull from: Gnu1/slashtmp:remove_extra_free
merge into: NRK:master
NRK:master
First-time contributor
Copy link

There is no point in freeing blocks at the end of a program, because all of the program’s space is given back to the system when the process terminates.

There is no point in freeing blocks at the end of a program, because all of the program’s space is given back to the system when the process terminates.
Owner
Copy link

All of these are just example code, not an actual program that will be used, so it's better for examples to be complete.

Beside, tomorrow someone else reading the code might think that free was mistakenly omitted and send another PR to add it back.

Also, you'll notice there's one instance of #ifdef DEBUG free() #endif. If these were actual programs, that is how I would deal with it.

In release build, there's no cost since the free calls gets removed. And in debug builds, it will satisfy runtime leak checkers and/or static analyzers. Furthermore, it signals to any human readers that the author didn't just forget to free, but it's an active choice to avoid free-ing in release builds, eliminating any possible confusion.

All of these are just example code, not an actual program that will be used, so it's better for examples to be complete. Beside, tomorrow someone else reading the code might think that `free` was mistakenly omitted and send another PR to add it back. Also, you'll notice there's one instance of `#ifdef DEBUG free() #endif`. If these were actual programs, that is how I would deal with it. In release build, there's no cost since the free calls gets removed. And in debug builds, it will satisfy runtime leak checkers and/or [static analyzers](https://nrk.neocities.org/articles/c-static-analyzers). Furthermore, it signals to any human readers that the author didn't just forget to `free`, but it's an active choice to avoid free-ing in release builds, eliminating any possible confusion.
NRK closed this pull request 2024年12月11日 11:16:30 +01:00

Pull request closed

Please reopen this pull request to perform a merge.
Sign in to join this conversation.
No reviewers
Milestone
Clear milestone
No items
No milestone
Projects
Clear projects
No items
No project
Assignees
Clear assignees
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
NRK/slashtmp!1
Reference in a new issue
NRK/slashtmp
No description provided.
Delete branch "Gnu1/slashtmp:remove_extra_free"

Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?