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

src: add uv__reallocf() #2735

Closed
wants to merge 1 commit into from
Closed

src: add uv__reallocf() #2735

wants to merge 1 commit into from

Conversation

bnoordhuis
Copy link
Member

Modeled after FreeBSD's reallocf(3): a version of realloc(3) that
frees the memory when reallocation fails, simplifying error handling in
many cases.

CI: https://ci.nodejs.org/job/libuv-test-commit/1784/

Modeled after FreeBSD's `reallocf(3)`: a version of `realloc(3)` that
frees the memory when reallocation fails, simplifying error handling in
many cases.
Copy link
Member

@santigimeno santigimeno left a comment

Choose a reason for hiding this comment

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

LGTM. Nice!

Comment on lines +107 to +109
if (newptr == NULL)
if (size > 0)
uv__free(ptr);
Copy link
Member

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?

Copy link
Member Author

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.

Copy link
Member

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.

cjihrig pushed a commit that referenced this pull request Mar 15, 2020
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>
@cjihrig
Copy link
Contributor

cjihrig commented Mar 15, 2020

Landed in 1bcfbfd. Thanks!

@cjihrig cjihrig closed this Mar 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants