Freeze on no memory available
This commit is contained in:
parent
41f7d978a9
commit
0f639ba3b1
1 changed files with 7 additions and 2 deletions
|
|
@ -6,6 +6,7 @@
|
|||
#include "Utils.hpp"
|
||||
#include "Debugging.hpp"
|
||||
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
|
||||
using namespace tp;
|
||||
|
|
@ -66,13 +67,17 @@ void* HeapAllocGlobal::allocate(ualni aBlockSize) {
|
|||
}
|
||||
|
||||
// 1) Allocate the block
|
||||
ALLOCATE:
|
||||
auto head = (MemHead*)malloc(aBlockSize + WRAP_SIZE * 2 + HEAD_SIZE);
|
||||
if (!head) {
|
||||
printf("WARNING : Cant allocate memory. Trying again\n");
|
||||
goto ALLOCATE; // Just freeze if no memory is available
|
||||
}
|
||||
|
||||
auto wrap_top = (int1*)(head + 1);
|
||||
auto data = wrap_top + WRAP_SIZE;
|
||||
auto wrap_bottom = data + aBlockSize;
|
||||
|
||||
if (!head) { return nullptr; }
|
||||
|
||||
head->mBlockSize = aBlockSize;
|
||||
head->mIgnored = mIgnore;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue