We have a 3P static kernel library (no sources) where they have denied a global ‘new’ and ‘delete’.
Our driver code is in C++ and we have had to define ‘new’ and ‘delete’ as well. We cant use theirs as they have other propitiatory memory management/tracking logic inside their new/del.
How does one go about on how to fix such scenarios?
I don’t know what you mean by “they have denied a global ‘new’ and ‘delete’.” It’s very easy to define your own operator new and delete that calls ExAllocatePoolWithTag. Until VS2015, Microsoft provided a very adequate implementation in <stdunk.h>, but they decided that was too dangerous for us poor programmers to handle. You can copy their implementation into your driver.
God almighty what a typo, I meant they have ‘defined’ not 'denied. So what I wrote was:
We have a 3P static kernel library (no sources) where they have defnied a global ‘new’ and ‘delete’.
Our driver code is in C++ and we have had to define ‘new’ and ‘delete’ as well. We cant use theirs as they have other propitiatory memory management/tracking logic inside their new/del.
How does one go about on how to fix such scenarios?
1 Move all of your code to a namespace, scope your global new/delete to that namespace. 2 if you have a class hierarchy, add the operators to the base class 3 add the operators to each class (you could get fancy, or lazy depending on your POV, by creating a macro to do define them to make your life simpler in the short run as a part of the experiment)
@Doron_Holan said:
1 Move all of your code to a namespace, scope your global new/delete to that namespace.
2 if you have a class hierarchy, add the operators to the base class
3 add the operators to each class (you could get fancy, or lazy depending on your POV, by creating a macro to do define them to make your life simpler in the short run as a part of the experiment)
@Doron_Holan#2 and #3 are already done, but #1 will break a lot of our code as then we have to move everything inside namespaced. Simple int x = new (int) wont work any more.
I seldom use C++, but I believe the changes would be limited to 1 line per compilation unit unless you need to mix calls to allocators within a single class. Even if you had to adjust each call, find / replace can do that for you expiditiously