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

fix: remove new/delete in net #1503

Merged

Conversation

cheniujh
Copy link
Collaborator

@cheniujh cheniujh commented May 14, 2023

fix #1477
removed new/delete operation in /src/net/* and use smart ptr instead.
Ps:not all new/delete are removed, for the variable that has flexible life circle, I choose to keep them as they were.

Ps:not all new/delete are removed, for the variable that has flexible life circle, I choose to keep them as they were.
@cheniujh
Copy link
Collaborator Author

net包中的修改:
1.尽量使用了unique_ptr。
2.对于生命周期灵活的(比如需要在特定情况下被delete的),依旧用的裸指针。
3.有些场景是:new出来了一个对象后,需要将该对象的裸指针传递给其他函数作为参数(主要是一些类的构造函数),改用智能指针以后,为了避免修改这些函数的参数类型,使用了unique_ptr::get()方法获取了裸指针传进去,但是这些裸指针在被传入这些函数之后,并没有类似delete的动作(函数内部没有影响其生命周期的行为),所以这些get()方法的使用应该是安全的。

@wanghenshui wanghenshui changed the title [task #1477]removed new/delete in /src/net/ fix: remove new/delete in net May 15, 2023
@AlexStocks AlexStocks merged commit f4bfb56 into OpenAtomFoundation:unstable May 22, 2023
7 checks passed
@cheniujh cheniujh deleted the remove_new_delete_net branch June 3, 2023 08:56
bigdaronlee163 pushed a commit to bigdaronlee163/pika that referenced this pull request Jun 8, 2024
* removed new/delete operation in /src/net/* and use smart ptr instead.
Ps:not all new/delete are removed, for the variable that has flexible life circle, I choose to keep them as they were.

* removed 2 delete operations that were skipped before

* removed more unique_ptr

---------

Co-authored-by: cjh <1271435567@qq.com>
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.

delete all new/delete in Pika and use shared_ptr/unique_ptr instead
4 participants