我们用new生成一个新的对象时,其实系统执行的操作时调用Heap API如下:
HANDLE hHeap = NULL;
hHeap = HeapCreate(0,50,0);
if(hHeap == NULL)
return;
PVOID m_pHeap = NULL;
m_pHeap = HeapAlloc(hHeap,HEAP_ZERO_MEMORY,100);
CString str = "1234567890";
memcpy(m_pHeap,str.GetBuffer(str.GetLength()),100);
HeapFree(hHeap,0,m_pHeap);
我们可以自己使用这些底层函数。
HANDLE hHeap = NULL;
hHeap = HeapCreate(0,50,0);
if(hHeap == NULL)
return;
PVOID m_pHeap = NULL;
m_pHeap = HeapAlloc(hHeap,HEAP_ZERO_MEMORY,100);
CString str = "1234567890";
memcpy(m_pHeap,str.GetBuffer(str.GetLength()),100);
HeapFree(hHeap,0,m_pHeap);
我们可以自己使用这些底层函数。
