Why does _get_heap_handle equal to GetProcessHeap?

前端 未结 4 1402
清歌不尽
清歌不尽 2020-12-20 06:21

According to this article, CRT uses separate heap (is it private heap?), but this little example shows that CRT heap and Default heap are the same

4条回答
  •  忘掉有多难
    2020-12-20 07:17

    The C Runtime source (malloc.c) shows that all the CRT allocations are created from _crtheap (which is what _get_heap_handle returns). In heapinit.c, _crtheap is set to GetProcessHeap. There's a separate allocation routine in smalheap.c that sets _crtheap to HeapCreate.

    However, it's not clear to me (there's no project file, unfortunately) which CRT versions use smalheap.c and which CRT versions use heapinit.c.

提交回复
热议问题