Allocation and Free memory from Heap
>> Friday, January 22, 2010
#include <windows.h> #include <iostream.h> int main() { HANDLE hHeap; int *a = NULL; // pointer to array int size = 100; hHeap = GetProcessHeap(); // receive handle of the process's heap a = (int*)HeapAlloc(hHeap, HEAP_ZERO_MEMORY, size *sizeof(int)); cout << " a[10] = " << a[10] << endl; HeapFree(hHeap, NULL, a); return 0; }
Functions to remember:
LPVOID HeapAlloc(HANDLE hHeap, DWORD dwFlags, SIZE_T dwBytes)I think the parameters are straight-forward here.
BOOL HeapFree(HANDLE hHeap, DWORD dwFlags, LPVOID lpMem)
0 comments:
Post a Comment