/* OSHeapTest.c */ #include "DHL_OSAL.h" /* ¸Þ¸ð¸® ÇÒ´çÀ» À§ÇÑ º¯¼ö¸¦ ¼±¾ðÇÏ°í ¸Þ¸ð¸® ÇÒ´ç ÀüÈÄÀÇ ÁÖ¼Ò È®ÀÎ ¸Þ¸ð¸® ¹Ýȯ ÈÄÀÇ ÁÖ¼Ò È®ÀÎ °á°ú : pMemÀÇ ÁÖ¼Ò°¡ 0x0 -> 0xXXXXXXXX -> 0x0 ¼ø¼­·Î Ãâ·ÂµÇ¸é Á¤»ó */ #define TEST_MALLOC_SIZE 1024 UINT32 size_heap; // size of entire heap UINT32 num_alloc_chunk; // number of alloc chunk UINT32 size_alloc; // total byte size alloc chunk UINT32 num_free_chunk; // number of free chunk UINT32 size_free; // total byte size free chunk static void print_heap_status(void) { DHL_OS_HEAP_STATUS status; DHL_OS_GetHeapStatus(&status); DHL_OS_Printf("size_heap = %x, num_alloc_chunk = %x, size_alloc = %x num_free_chunk=%x, size_free=%x \n", status.size_heap, status.num_alloc_chunk, status.size_alloc, status.num_free_chunk, status.size_free); } void OS_HeapTest(void) { int* pMem = 0; DHL_OS_Printf( "\r\n----OS Heap Test----\r\n\r\n"); DHL_OS_Printf( "The value of \'pMem\' before malloc is 0x%x\r\n", pMem); print_heap_status(); pMem = DHL_OS_Malloc(TEST_MALLOC_SIZE); DHL_OS_Printf( "The value of \'pMem\' after malloc is 0x%x\r\n", pMem); if (pMem == 0) DHL_OS_Printf( "Malloc is failed..\r\n"); print_heap_status(); DHL_OS_Free((void**)&pMem); DHL_OS_Printf("The value of \'pMem\' after free.. 0x%x\r\n", pMem); print_heap_status(); }