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: Modernized unique_ptr construction #31654

Closed
wants to merge 2 commits into from
Closed

src: Modernized unique_ptr construction #31654

wants to merge 2 commits into from

Conversation

Yuhanun
Copy link

@Yuhanun Yuhanun commented Feb 5, 2020

  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • commit message follows [commit guidelines]

A simple first contribution.

std::unique_ptr's constructor can lead to memory leaks if the constructed value, allocated through new, throws an exception or something that causes an immediate backtrace on the callstack.

std::make_unique prevents this by allocating the memory for you, making it safer. Not only does it make it safer, it also makes it more readable.

I'm not sure whether I followed every guideline with this, but I hope I did.

@nodejs-github-bot nodejs-github-bot added the c++ Issues and PRs that require attention from people who are familiar with C++. label Feb 5, 2020
@Yuhanun Yuhanun changed the title Modernized unique_ptr construction src: Modernized unique_ptr construction Feb 5, 2020
Copy link
Member

@addaleax addaleax left a comment

Choose a reason for hiding this comment

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

LGTM

Just as a side note, exceptions aren’t enabled in the Node.js source tree :)

jasnell
jasnell previously approved these changes Feb 5, 2020
@Yuhanun
Copy link
Author

Yuhanun commented Feb 5, 2020

LGTM

Just as a side note, exceptions aren’t enabled in the Node.js source tree :)

Ah okay, well my bad for that :) Didn't know that, good to know though since I'm looking to make more contributions to the project :)

@addaleax
Copy link
Member

addaleax commented Feb 5, 2020

@Yuhanun It’s all good – like you said, it also makes the code more readable. 👍

src/debug_utils.cc Outdated Show resolved Hide resolved
@jasnell jasnell dismissed their stale review February 6, 2020 15:12

One of the changes needs fixing

Copy link
Member

@jasnell jasnell left a comment

Choose a reason for hiding this comment

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

Needs @TimothyGu's suggestion added

Co-Authored-By: Timothy Gu <timothygu99@gmail.com>
@addaleax addaleax added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Feb 6, 2020
@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@addaleax
Copy link
Member

addaleax commented Feb 8, 2020

Landed in 9c753b3, thanks for the PR! 🎉

@addaleax addaleax closed this Feb 8, 2020
addaleax pushed a commit that referenced this pull request Feb 8, 2020
PR-URL: #31654
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: David Carlier <devnexen@gmail.com>
Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
codebytere pushed a commit that referenced this pull request Feb 17, 2020
PR-URL: #31654
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: David Carlier <devnexen@gmail.com>
Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
@codebytere codebytere mentioned this pull request Feb 17, 2020
codebytere pushed a commit that referenced this pull request Mar 15, 2020
PR-URL: #31654
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: David Carlier <devnexen@gmail.com>
Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
codebytere pushed a commit that referenced this pull request Mar 17, 2020
PR-URL: #31654
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: David Carlier <devnexen@gmail.com>
Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
@codebytere codebytere mentioned this pull request Mar 17, 2020
codebytere pushed a commit that referenced this pull request Mar 30, 2020
PR-URL: #31654
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: David Carlier <devnexen@gmail.com>
Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author ready PRs that have at least one approval, no pending requests for changes, and a CI started. c++ Issues and PRs that require attention from people who are familiar with C++.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants