replace alloc_re() with plain realloc() - #151
Merged
Merged
Conversation
There are different types passed in to alloc_re(), which never raised an error before as there were no arguments in the header files. Make it void** so it's clear that this is just anonymous memory.
It was called from only 2 places and had a slightly unusual interface. Since those lines have been changed already they would collide in a diff anyway, so change them to use realloc() directly, which is a known interface for anyone that wants to change this lines again. The conversion rules are simply: pass x instead of &x as first argument, and simply remove the second one. Do the usual realloc() return value checking and assignment at the callsite. This has the implicit bonus that another allocation function now uses size_t.
DerDakon
requested review from
alanpost,
jlmuir,
josuah,
leahneukirchen,
mbhangui,
schmonz and
xenotrope
June 13, 2020 13:07
leahneukirchen
approved these changes
Jun 13, 2020
mbhangui
approved these changes
Jun 13, 2020
mbhangui
left a comment
Contributor
There was a problem hiding this comment.
This change also makes the code simpler compared to earlier.
I'm wondering why djb didn't make the same realloc() interface for alloc_re() ?
Member
Author
|
I assume that he want a simple interface where he could check the return value and does not have to assign anything afterwards, which is indeed a bit cumbersome for realloc(). |
schmonz
approved these changes
Jun 14, 2020
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
It is only used at 2 places, and needs overhaul anyway to get rid of compiler warnings. See more rationale in the commit messages.