| 1 | // -*- C++ -*- |
| 2 | |
| 3 | /* |
| 4 | |
| 5 | Heap Layers: An Extensible Memory Allocation Infrastructure |
| 6 | |
| 7 | Copyright (C) 2000-2020 by Emery Berger |
| 8 | http://www.emeryberger.com |
| 9 | [email protected] |
| 10 | |
| 11 | Heap Layers is distributed under the terms of the Apache 2.0 license. |
| 12 | |
| 13 | You may obtain a copy of the License at |
| 14 | http://www.apache.org/licenses/LICENSE-2.0 |
| 15 | |
| 16 | */ |
| 17 | |
| 18 | #ifndef HL_EXACTLYONEHEAP_H |
| 19 | #define HL_EXACTLYONEHEAP_H |
| 20 | |
| 21 | #include "utility/exactlyone.h" |
| 22 | |
| 23 | namespace HL { |
| 24 | |
| 25 | template <class Heap> |
| 26 | class ExactlyOneHeap : public HL::ExactlyOne<Heap> { |
| 27 | public: |
| 28 | |
| 29 | enum { Alignment = Heap::Alignment }; |
| 30 | |
| 31 | inline void * malloc (size_t sz) { |
| 32 | return (*this)().malloc (sz); |
| 33 | } |
| 34 | inline void free (void * ptr) { |
| 35 | (*this)().free (ptr); |
| 36 | } |
| 37 | inline void free (void * ptr, size_t sz) { |
| 38 | (*this)().free (ptr, sz); |
| 39 | } |
| 40 | inline size_t getSize (void * ptr) { |
| 41 | return (*this)().getSize (ptr); |
| 42 | } |
| 43 | inline int getClass (void * ptr) { |
| 44 | return (*this)().getClass (ptr); |
| 45 | } |
| 46 | inline void clear() { |
| 47 | (*this)().clear(); |
| 48 | } |
| 49 | inline void lock() { |
| 50 | (*this)().lock(); |
| 51 | } |
| 52 | inline void unlock() { |
| 53 | (*this)().unlock(); |
| 54 | } |
| 55 | }; |
| 56 | |
| 57 | } |
| 58 | |
| 59 | #endif |