Jump to content
  • Advertisement
Sign in to follow this  
KEXIK

C++ pointers in two dlls

This topic is 3653 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi! I have simple question to C++ win32 gurus. I have exe and few dlls, which are loaded dynamicaly using LoadLibrary(). When I allocate memory in one module or open a file using stdio FILE* fp=fopen() and then pass this pointer to second modude, I cannot delete this memory or write to this file. For example when I delete this memory allocated in other module I get: HEAP[test.exe]: Invalid Address specified to RtlValidateHeap( 00CD0000, 00DE2A88 ) Is it normal?

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by KEXIK
For example when I delete this memory allocated in other module I get: HEAP[test.exe]: Invalid Address specified to RtlValidateHeap( 00CD0000, 00DE2A88 )

Is it normal?

Yes. Each DLL has its own private allocation pool, its own private pool of file descriptors, etc. They cannot be allocated by one module and freed by another. File pointers are even worse, because they cannot be even used reliably in another DLL as the one they were created in.

So either make sure you always free the memory or use the FP in the same module they were created, or simply link to the DLL version of the MS CRT.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!