1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
| #include<stdio.h> #include<string.h> #include <windows.h>
int main() { int *heap; unsigned short int size; char *pheap1,*pheap2; HANDLE hHeap;
printf("请输入size数值:\n"); scanf("%d",&size); hHeap=HeapCreate(HEAP_GENERATE_EXCEPTIONS,0X100,0XFFF);
if(size<=0X50) { size-=5; printf("size:%d\n",size); pheap1=HeapAlloc(hHeap,0,size); pheap2=HeapAlloc(hHeap,0,0X50); } HeapFree(hHeap,0,pheap1); HeapFree(hHeap,0,pheap2); return 0; }
|