| 1 | // -*- C++ -*-cxx . . $ `<file>/vendor/Heap-Layers/heaps/top/staticheap.h`/ |
| 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 | |
| 19 | /* |
| 20 | |
| 21 | StaticHeap: manage a fixed range of memory. |
| 22 | |
| 23 | */ |
| 24 | |
| 25 | #ifndef HL_STATICHEAP_H |
| 26 | #define HL_STATICHEAP_Hcxx . . $ `vendor/Heap-Layers/heaps/top/staticheap.h:26:9`! |
| 27 | |
| 28 | #include <cstddef> |
| 29 | |
| 30 | namespace HLcxx . . $ HL/ { |
| 31 | |
| 32 | template <int MemorySize> |
| 33 | class StaticHeapcxx . . $ HL/StaticHeap# { |
| 34 | public: |
| 35 | |
| 36 | StaticHeapcxx . . $ HL/StaticHeap#`StaticHeap<MemorySize>`(49f6e7a06ebc5aa8).() |
| 37 | : _ptrcxx . . $ HL/StaticHeap#_ptr. (&cxx . . $ std/`operator&`(3fbb01592cd53f2a)._bufcxx . . $ HL/StaticHeap#_buf.[0]), |
| 38 | _remainingcxx . . $ HL/StaticHeap#_remaining. (MemorySize) |
| 39 | {} |
| 40 | |
| 41 | enumcxx . . $ HL/StaticHeap#$anonymous_type_0# { Alignmentcxx . . $ HL/StaticHeap#Alignment. = 1 }; |
| 42 | |
| 43 | inline void * malloccxx . . $ HL/StaticHeap#malloc(bfcfa4d6b7f7ef64). (size_t sz) { |
| 44 | if (_remainingcxx . . $ HL/StaticHeap#_remaining. < sz) { |
| 45 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 46 | } |
| 47 | void * p = _ptrcxx . . $ HL/StaticHeap#_ptr.; |
| 48 | _ptrcxx . . $ HL/StaticHeap#_ptr. += sz; |
| 49 | _remainingcxx . . $ HL/StaticHeap#_remaining. -= sz; |
| 50 | return p; |
| 51 | } |
| 52 | |
| 53 | void freecxx . . $ HL/StaticHeap#free(5d22bdacc48458e8). (void *) {} |
| 54 | int removecxx . . $ HL/StaticHeap#remove(dedf1e9b1c614a07). (void *) { return 0; } |
| 55 | |
| 56 | int isValidcxx . . $ HL/StaticHeap#isValid(dedf1e9b1c614a07). (void * ptr) { |
| 57 | return (((size_t) ptr >= (size_t) _bufcxx . . $ HL/StaticHeap#_buf.) && |
| 58 | ((size_t) ptr < (size_t) _bufcxx . . $ HL/StaticHeap#_buf.)); |
| 59 | } |
| 60 | |
| 61 | private: |
| 62 | |
| 63 | // Disable copying and assignment. |
| 64 | StaticHeapcxx . . $ HL/StaticHeap#`StaticHeap<MemorySize>`(defc92fe00430d26). (const StaticHeap&); |
| 65 | StaticHeap& operatorcxx . . $ HL/StaticHeap#`operator=`(5da5811febbf1693).= (const StaticHeap&); |
| 66 | |
| 67 | char _bufcxx . . $ HL/StaticHeap#_buf.[MemorySize]; |
| 68 | char * _ptrcxx . . $ HL/StaticHeap#_ptr.; |
| 69 | size_t _remainingcxx . . $ HL/StaticHeap#_remaining.; |
| 70 | }; |
| 71 | |
| 72 | } |
| 73 | |
| 74 | #endif |