加入分配失败的日志
This commit is contained in:
parent
1b495d9490
commit
258835798e
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue