1

Possible Duplicate:
malloc() vs. HeapAlloc()

I know we can use malloc/free in C to allocate/release heap memory, and use new/delete in C++ to do the similar things.

As for Windows, I occasionally saw people use HeapAlloc etc APIs to allocate memory, which are the differences from the C/C++ counterparts?

And which is the best way to allocate a wchar_t buffer on heap which will be used as input for some Windows APIs?

Community
  • 1
  • 1
Zhi Wang
  • 1,138
  • 4
  • 20
  • 34

1 Answers1

1

malloc/new are implemented using HeapAlloc, so there is very little practical difference. There are of course the implementation differences; malloc will return null on failure, new will throw, etc.

Terry Mahaffey
  • 11,775
  • 1
  • 35
  • 44