Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does DLL new/delete override the user code new/delete?

Tags:

c++

visual-c++

guys, If I override the global new and delete in my dll code, will this override the user code new and delete? I made a test, and it shows the user new and delete will not be impacted. If I want to make user code new and delete be replaced by mine sdk new/delete, how to do that.

What's the case of template class. Template class definition includes some new/delete. And user code might instantiate it. Then, it might use user new/delete, right?

like image 234
giggle Avatar asked Apr 27 '11 09:04

giggle


1 Answers

No, on Windows each DLL has its own operator new()/operator delete(). However you should be careful - if some DLL news an object that object should be deleted using the same operator delete() - otherwise you run into undefined behavior.

like image 195
sharptooth Avatar answered Oct 04 '22 22:10

sharptooth