Raised This Month: $32 Target: $400
 8% 

use "delete" without "new" before, I can't take it.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
little_froy
Senior Member
Join Date: May 2021
Old 06-22-2021 , 01:52   use "delete" without "new" before, I can't take it.
Reply With Quote #1

new and delete means the stack varibles has less stability and compatibility in C++.
and the varible should use "new" to alloc memory, and use "delete" paired to free memory.
everything is fine with i "new" a Menu class obj, and delete it at MenuAction_Select::MenuAction_End.
but I try to avoid it with alonly "delete", so I use KillTimer() but not it.
I'm not able to continue the sql code cause in the first part of the course, it use "delete" with out "new" again.
although it's lke unique_ptr, shared_ptr, weak_ptr in C++ , when how spurcepawn interal works....

Last edited by little_froy; 06-22-2021 at 02:05.
little_froy is offline
Silvers
SourceMod Plugin Approver
Join Date: Aug 2010
Location: SpaceX
Old 06-22-2021 , 03:50   Re: use "delete" without "new" before, I can't take it.
Reply With Quote #2

https://forums.alliedmods.net/showthread.php?t=300403 see post #7
__________________

Last edited by Silvers; 06-22-2021 at 03:51.
Silvers is offline
little_froy
Senior Member
Join Date: May 2021
Old 06-22-2021 , 08:23   Re: use "delete" without "new" before, I can't take it.
Reply With Quote #3

Quote:
Originally Posted by Silvers View Post
that means i can use CloseHandle() instead of "delete" however it's not only for timer but any handle ?

Last edited by little_froy; 06-22-2021 at 08:23.
little_froy is offline
Silvers
SourceMod Plugin Approver
Join Date: Aug 2010
Location: SpaceX
Old 06-22-2021 , 08:38   Re: use "delete" without "new" before, I can't take it.
Reply With Quote #4

delete was added to basically replace CloseHandle and KillTimer. It can be used for all handles that can be closed.
__________________

Last edited by Silvers; 06-22-2021 at 09:07.
Silvers is offline
Psyk0tik
Veteran Member
Join Date: May 2012
Location: Homeless
Old 06-22-2021 , 08:42   Re: use "delete" without "new" before, I can't take it.
Reply With Quote #5

You can use "delete" on any handle that is closeable. (Timers, DataPacks, Menus, ArrayLists, StringMaps, KeyValues, etc.)

Not all handles are closeable though. (ConVars, Protobufs, etc.)
__________________
Psyk0tik is offline
little_froy
Senior Member
Join Date: May 2021
Old 06-22-2021 , 09:22   Re: use "delete" without "new" before, I can't take it.
Reply With Quote #6

Quote:
Originally Posted by Crasher_3637 View Post
You can use "delete" on any handle that is closeable. (Timers, DataPacks, Menus, ArrayLists, StringMaps, KeyValues, etc.)

Not all handles are closeable though. (ConVars, Protobufs, etc.)
thanks
little_froy is offline
little_froy
Senior Member
Join Date: May 2021
Old 06-22-2021 , 09:22   Re: use "delete" without "new" before, I can't take it.
Reply With Quote #7

Quote:
Originally Posted by Silvers View Post
delete was added to basically replace CloseHandle and KillTimer. It can be used for all handles that can be closed.
thanks
little_froy is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 22:57.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode