Assuming that EXE and DLL use the same compiler and STL version. If I use a std::vector in my EXE and use reserve to reserve memory. Then I pass it as reference to a DLL.
I do a push_back in the DLL to add an element to my vector. If I do not exceed actual capacity, is the memory of the new element allocated in the DLL or in the EXE ?
This is generally a bad idea.
When you call push_back
, a copy can be made of whichever object you are adding to the vector. There is no guarantee that the size of that object (among other things) is the same as the size reserved in the .exe via std::vector::reserve
. Both binaries may have been compiled with a different version of the STL.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With