Divide Framework 0.1
A free and open-source 3D Framework under heavy development
Loading...
Searching...
No Matches
LinearAllocator.h
Go to the documentation of this file.
1/*
2 Author : Tobias Stein
3 Date : 22nd October, 2016
4 File : LinearAllocator.h
5
6 Linear allocator.
7
8 All Rights Reserved. (c) Copyright 2016.
9*/
10
11#pragma once
12#ifndef ECS__LINEAR_ALLOC_H__
13#define ECS__LINEAR_ALLOC_H__
14
16
17namespace ECS { namespace Memory { namespace Allocator {
18
19 /*
20 Allocates memory in a linear way.
21
22 first 2 3 4
23 allocatation alloaction
24 v v v v
25 |=================|=====|==|======| .... |
26 ^ ^
27 Initialial Last possible
28 memory memory address
29 address (mem + memSize)
30 (mem)
31
32
33 memory only can be freed by clearing all allocations
34 */
36 {
37 public:
38
39 LinearAllocator(size_t memSize, const void* mem);
40
41 virtual ~LinearAllocator();
42
43 virtual void* allocate(size_t size, u8 alignment) override;
44 virtual void free(void* p) override;
45 virtual void clear() override;
46
47 }; // class LineaerAllocator
48
49} } } // namespace ECS::Memory::Allocator
50
51#endif // ECS__LINEAR_ALLOC_H__
#define ECS_API
Definition: Platform.h:16
uint8_t u8
Definition: Platform.h:49