Skip to content
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

replace alloc_re() with plain realloc() #151

Merged
merged 2 commits into from
Jun 14, 2020
Merged

replace alloc_re() with plain realloc() #151

merged 2 commits into from
Jun 14, 2020

Conversation

DerDakon
Copy link
Member

It is only used at 2 places, and needs overhaul anyway to get rid of compiler warnings. See more rationale in the commit messages.

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.
Copy link
Contributor

@mbhangui mbhangui left a comment

Choose a reason for hiding this comment

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

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() ?

@DerDakon
Copy link
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().

@DerDakon DerDakon merged commit c556526 into master Jun 14, 2020
@DerDakon DerDakon deleted the Dakon-realloc branch June 14, 2020 13:47
@schmonz schmonz modified the milestones: 1.90, 1.09 Sep 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants