see ya later allocator

This commit is contained in:
IlyaShurupov 2024-03-22 14:05:03 +03:00
parent d7bc7e10ab
commit aa53a4addb
44 changed files with 32 additions and 1693 deletions

View file

@ -4,8 +4,6 @@
#include "primitives/nullobject.h"
#include "HeapAllocatorGlobal.hpp"
#include <malloc.h>
namespace obj {
@ -26,7 +24,7 @@ namespace obj {
};
Object* ObjectMemAllocate(const ObjectType* type) {
ObjectMemHead* memh = (ObjectMemHead*) tp::HeapAllocGlobal::allocate(type->size + sizeof(ObjectMemHead));
ObjectMemHead* memh = (ObjectMemHead*) malloc(type->size + sizeof(ObjectMemHead));
if (!memh) {
return NULL;
}
@ -62,7 +60,7 @@ namespace obj {
bottom = memh->up;
}
tp::HeapAllocGlobal::deallocate(memh);
free(memh);
count--;
}

View file

@ -1,6 +1,4 @@
#include "HeapAllocatorGlobal.hpp"
#include "core/scriptsection.h"
using namespace obj;
@ -17,7 +15,7 @@ void set_script_head_store_adress(Script* in, tp::alni address) { ((script_data_
tp::alni get_script_head_store_adress(Script* in) { return ((script_data_head*) in - 1)->store_adress; }
Script* ScriptSection::createScript() {
auto sdhead = (script_data_head*) tp::HeapAllocGlobal::allocate(sizeof(script_data_head) + sizeof(Script));
auto sdhead = (script_data_head*) malloc(sizeof(script_data_head) + sizeof(Script));
auto out = (Script*) (sdhead + 1);
if (!sdhead) {
@ -39,7 +37,7 @@ void ScriptSection::delete_script(Script* script) {
script->~Script();
obj::NDO->destroy(script->mReadable);
tp::HeapAllocGlobal::deallocate((((script_data_head*) script) - 1));
free((((script_data_head*) script) - 1));
}
void ScriptSection::reference_script(Script* script) { (((script_data_head*) script) - 1)->refc++; }

View file

@ -27,7 +27,7 @@ obj::Object* ScopeStack::getLocalUtil(Scope& scope, tp::String* id) {
}
ScopeStack::ScopeStack() {
mBuff = (Scope*) tp::HeapAllocGlobal::allocate(sizeof(Scope) * MAX_STACK_SIZE);
mBuff = (Scope*) malloc(sizeof(Scope) * MAX_STACK_SIZE);
mIdx = 0;
mIterIdx = 0;
}
@ -80,4 +80,4 @@ obj::Object* ScopeStack::getLocal(tp::String& str) {
Scope* ScopeStack::getCurrentScope() { return &mBuff[mIdx - 1]; }
ScopeStack::~ScopeStack() { tp::HeapAllocGlobal::deallocate(mBuff); }
ScopeStack::~ScopeStack() { free(mBuff); }