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
src: add uv__reallocf() #2735
src: add uv__reallocf() #2735
Conversation
Modeled after FreeBSD's `reallocf(3)`: a version of `realloc(3)` that frees the memory when reallocation fails, simplifying error handling in many cases.
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.
LGTM. Nice!
if (newptr == NULL) | ||
if (size > 0) | ||
uv__free(ptr); |
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.
Maybe wrapping these conditionals into one?
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.
You mean with &&
? The two-if-statements style is pretty pervasive throughout libuv.
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.
Yeah, I meant that. It was just a suggestion. I'm fine either way.
Modeled after FreeBSD's `reallocf(3)`: a version of `realloc(3)` that frees the memory when reallocation fails, simplifying error handling in many cases. PR-URL: #2735 Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Landed in 1bcfbfd. Thanks! |
Modeled after FreeBSD's
reallocf(3)
: a version ofrealloc(3)
thatfrees the memory when reallocation fails, simplifying error handling in
many cases.
CI: https://ci.nodejs.org/job/libuv-test-commit/1784/