Supposed I have a dll with an API consisting of:
void someFunc(std::string arg);
I call it from within an MFC application as so:
someFunc("my string");
My understanding is that the constructor for std::string is called in my application's context (i.e., the memory for the string class is allocated on the stack, and then the dynamic memory internally allocated by the copy constructor is allocated on the my applications heap by my applications version of the c runtime library)
My question is, when exactly is the destructor called in relation to the return from the function call and corresponding runtime library/heap switch? Is it while still within the context of the dll? If so, I'm thinking that this would result in the dll's c runtime library attempting to delete the std::string's internal dynamically allocated storage from it's heap resulting in the apparent heap corruption I'm encountering.
Or am I barking up the wrong tree? (I'm rather new to this whole dll thing...)
void someFunc(std::string arg);
I call it from within an MFC application as so:
someFunc("my string");
My understanding is that the constructor for std::string is called in my application's context (i.e., the memory for the string class is allocated on the stack, and then the dynamic memory internally allocated by the copy constructor is allocated on the my applications heap by my applications version of the c runtime library)
My question is, when exactly is the destructor called in relation to the return from the function call and corresponding runtime library/heap switch? Is it while still within the context of the dll? If so, I'm thinking that this would result in the dll's c runtime library attempting to delete the std::string's internal dynamically allocated storage from it's heap resulting in the apparent heap corruption I'm encountering.
Or am I barking up the wrong tree? (I'm rather new to this whole dll thing...)
Last edited: