Is there a fundamental difference between malloc and HeapAlloc (aside from the portability)?
- 阅读更多 关于 Is there a fundamental difference between malloc and HeapAlloc (aside from the portability)?
问题 I'm having code that, for various reasons, I'm trying to port from the C runtime to one that uses the Windows Heap API. I've encountered a problem: If I redirect the malloc / calloc / realloc / free calls to HeapAlloc / HeapReAlloc / HeapFree (with GetProcessHeap for the handle), the memory seems to be allocated correctly (no bad pointer returned, and no exceptions thrown), but the library I'm porting says "failed to allocate memory" for some reason. I've tried this both with the Microsoft