加入分配失败的日志

This commit is contained in:
大石头X2 2017-02-22 19:43:11 +08:00
parent 1b495d9490
commit 258835798e
1 changed files with 8 additions and 0 deletions

View File

@ -52,6 +52,12 @@ void* Heap::Alloc(uint size)
// 要申请的内存大小需要对齐
size = (size+MEMORY_ALIGN-1) & (~(MEMORY_ALIGN-1));
if(size > Size - _Used)
{
debug_printf("Heap::Alloc %d > %d 失败! \r\n", size, Size - _Used);
return nullptr;
}
void* ret = nullptr;
int need = size + sizeof(MemoryBlock);
@ -77,6 +83,8 @@ void* Heap::Alloc(uint size)
}
}
if(!ret) debug_printf("Heap::Alloc %d 失败!\r\n", size);
return ret;
}