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