Skip to content
Snippets Groups Projects
Commit 34020ba2 authored by j2-mcdaid's avatar j2-mcdaid :skull_crossbones:
Browse files

Upload New File

parent f722d485
Branches
Tags
No related merge requests found
#ifndef ALLOCATOR_TPP
#define ALLOCATOR_TPP
#include "allocator.hpp"
template <typename T>
T* bAllocator::alloc(size_t count){
// finds required memory space needed
size_t total_size = count * sizeof(T);
// check there is enough space in the stack
if (reinterpret_cast<char*>(next) + total_size >
reinterpret_cast<char*>(heap_start) + heap_size){
return nullptr; // pointer representing false
}
T* result = static_cast<T*>(next);
next = reinterpret_cast<char*>(next) + total_size;
a_count++;
return result;
}
#endif
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment