Skip to content

replace alloc_re() with plain realloc() - #151

Merged
DerDakon merged 2 commits into
masterfrom
Dakon-realloc
Jun 14, 2020
Merged

DerDakon merged 2 commits into
masterfrom
Dakon-realloc

Conversation

@DerDakon

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

DerDakon added 2 commits June 13, 2020 14:55
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.

@mbhangui mbhangui left a comment

Copy link
Copy Markdown
Contributor

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
Copy Markdown
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