views:

280

answers:

2

I am calling a C DLL from a Delphi 2009 application and I keep getting errors when memory allocated by GetMem or AllocMem is passed to the DLL. The only way around I could avoid these errors was by using malloc from msvcrt.dll. What is malloc doing that the built-in memory routines aren't, and how can I get the built-in ones to work? I really don't like bypassing the built-in memory manager.

+5  A: 

If the DLL ever attempts to free that memory or otherwise manipulate the memory allocation (e.g. expand/contract it), that would explain it. Mixing memory allocation systems is not recommended.

qid
A: 

Pay attention to Calling Convention, stdcall or cdecl .

Pham