1 | //************************************ bs::framework - Copyright 2018 Marko Pintera **************************************// |
2 | //*********** Licensed under the MIT license. See LICENSE.md for full terms. This notice is not to be removed. ***********// |
3 | #pragma once |
4 | |
5 | namespace bs |
6 | { |
7 | /** @addtogroup Internal-Utility |
8 | * @{ |
9 | */ |
10 | |
11 | /** @addtogroup Memory-Internal |
12 | * @{ |
13 | */ |
14 | |
15 | /** |
16 | * Specialized allocator for profiler so we can avoid tracking internal profiler memory allocations which would skew |
17 | * profiler results. |
18 | */ |
19 | class ProfilerAlloc |
20 | {}; |
21 | |
22 | /** Memory allocator providing a generic implementation. Specialize for specific categories as needed. */ |
23 | template<> |
24 | class MemoryAllocator<ProfilerAlloc> : public MemoryAllocatorBase |
25 | { |
26 | public: |
27 | /** Allocates the given number of bytes. */ |
28 | static void* allocate(size_t bytes) |
29 | { |
30 | return malloc(bytes); |
31 | } |
32 | |
33 | /** Frees memory previously allocated with allocate(). */ |
34 | static void free(void* ptr) |
35 | { |
36 | ::free(ptr); |
37 | } |
38 | }; |
39 | |
40 | /** @} */ |
41 | /** @} */ |
42 | } |