Debian Codegraph @

vendor/Heap-Layers/heaps/buildingblock/adaptheap.h

raw symbols SCIP
1 // -*- C++ -*-cxx . . $ `<file>/vendor/Heap-Layers/heaps/buildingblock/adaptheap.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 #ifndef HL_ADAPTHEAP_H
20 #define HL_ADAPTHEAP_Hcxx . . $ `vendor/Heap-Layers/heaps/buildingblock/adaptheap.h:20:9`!
21
22 #include <assert.h>
23 #include <stdlib.h>
24
25 /**
26 * @class AdaptHeap
27 * @brief Maintains dictionary entries through freed objects.
28 * Sample dictionaries include DLList and SLList.
29 */
30
31 namespace HLcxx . . $ HL/ {
32
33 template <class Dictionary, class SuperHeap>
34 class AdaptHeapcxx . . $ HL/AdaptHeap# : public SuperHeap {
35 public:
36
37 enumcxx . . $ HL/AdaptHeap#$anonymous_type_0# { Alignmentcxx . . $ HL/AdaptHeap#Alignment. = SuperHeap::Alignment };
38
39 /// Allocate an object (remove from the dictionary).
40 inline void * malloccxx . . $ HL/AdaptHeap#malloc(bfcfa4d6b7f7ef64). (const size_t) {
41 void * ptr = (Entrycxx . . $ HL/AdaptHeap#Entry# *) dictcxx . . $ HL/AdaptHeap#dict..get();
42 if (ptr) {
43 assertcxx . . $ `/usr/include/assert.h:50:10`! (SuperHeap::getSize(ptr) >= sizeof(dict));
44 }
45 return ptr;
46 }
47
48 /// Deallocate the object (return to the dictionary).
49 inline void freecxx . . $ HL/AdaptHeap#free(5d22bdacc48458e8). (void * ptr) {
50 if (ptr) {
51 assertcxx . . $ `/usr/include/assert.h:50:10`! (SuperHeap::getSize(ptr) >= sizeof(dict));
52 Entrycxx . . $ HL/AdaptHeap#Entry# * entry = (Entrycxx . . $ HL/AdaptHeap#Entry# *) ptr;
53 dictcxx . . $ HL/AdaptHeap#dict..insert (entry);
54 }
55 }
56
57 /// Remove an object from the dictionary.
58 inline int removecxx . . $ HL/AdaptHeap#remove(dedf1e9b1c614a07). (void * ptr) {
59 if (ptr) {
60 assertcxx . . $ `/usr/include/assert.h:50:10`! (SuperHeap::getSize(ptr) >= sizeof(dict));
61 dictcxx . . $ HL/AdaptHeap#dict..remove ((Entrycxx . . $ HL/AdaptHeap#Entry# *) ptr);
62 }
63 return 1;
64 }
65
66 /// Clear the dictionary.
67 inline void clearcxx . . $ HL/AdaptHeap#clear(49f6e7a06ebc5aa8). (void) {
68 Entrycxx . . $ HL/AdaptHeap#Entry# * ptr;
69 while ((ptr = (Entrycxx . . $ HL/AdaptHeap#Entry# *) dictcxx . . $ HL/AdaptHeap#dict..get()) != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) {
70 SuperHeap::free (ptr);
71 }
72 dictcxx . . $ HL/AdaptHeap#dict..clear();
73 SuperHeap::clear();
74 }
75
76
77 private:
78
79 /// The dictionary object.
80 Dictionary dictcxx . . $ HL/AdaptHeap#dict.;
81
82 class Entrycxx . . $ HL/AdaptHeap#Entry# : public Dictionary::Entry {};
83 };
84
85 }
86
87 #endif // HL_ADAPTHEAP