Why does my program crash if I call malloc instead of GetMem?

I call the C DLL from a Delphi 2009 application, and I keep getting errors when the memory allocated by GetMem or AllocMem is transferred to the DLL. The only way to avoid these errors is to use malloc from msvcrt.dll. What is malloc, that the built-in memory functions are not, and how can I make the built-in work? I really don't like going around the built-in memory manager.

+3
source share
2 answers

If the DLL ever tries to free this memory or otherwise manipulate the memory allocation (for example, expand / compress it), this will explain it. Mixing memory allocation systems is not recommended.

+4
source

Pay attention to Calling Convention, stdcall or cdecl,

0
source

Source: https://habr.com/ru/post/1722466/


All Articles