Are the cross dll allocations ok?

If I have an application that uses at least two dlls, is it generally safe to allocate resources in one dll and free them in the other?

I am thinking specifically about calling fopen and fclose in different dlls, but I would also like to know that it is safe for other resources (memory pointers, descriptors, etc.).

I think as long as everything is compiled with the same switches it should work.

Thanks, Cory

0


a source to share


2 answers


This is Bad Thing (TM) for all but non-trivial projects. This works under a very strict set of conditions such as DLL version, threading model, memory allocators used in each and many others. Finally, mistakes will be too difficult to pursue.



+3


a source


As long as you are using the DLL version of the C runtime library (/ MD or / MDd), then yes, it is safe.



If you statically link the CRT to the DLL (/ MT or / MTd) then no, it is not secure.

0


a source







All Articles