Debian Codegraph @

vendor/Heap-Layers/heaps/debug/debugheap.h

raw symbols SCIP
1 /* -*- C++ -*- */cxx . . $ `<file>/vendor/Heap-Layers/heaps/debug/debugheap.h`/
2
3
4 #ifndef HL_DEBUGHEAP_H_
5 #define HL_DEBUGHEAP_H_cxx . . $ `vendor/Heap-Layers/heaps/debug/debugheap.h:5:9`!
6
7 #include <assert.h>
8 #include <stdlib.h>
9
10 /**
11 *
12 *
13 */
14
15 namespace HLcxx . . $ HL/ {
16
17 template <class Super,
18 char freeChar = 'F'>
19 class DebugHeapcxx . . $ HL/DebugHeap# : public Super {
20 private:
21
22 enumcxx . . $ HL/DebugHeap#$anonymous_type_0# { CANARYcxx . . $ HL/DebugHeap#CANARY. = 0xdeadbeef };
23
24 public:
25
26 // Fill with A's.
27 inline void * malloccxx . . $ HL/DebugHeap#malloc(bfcfa4d6b7f7ef64). (size_t sz) {
28 // Add a guard area at the end.
29 void * ptr;
30 ptr = Super::malloc (sz + sizeof(size_t));
31 if (ptr == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) {
32 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
33 }
34 size_t realSize = Super::getSize (ptr);
35 assertcxx . . $ `/usr/include/assert.h:50:10`! (realSize >= sz);
36 for (size_t i = 0; i < realSize; i++) {
37 ((char *) ptr)[i] = 'A';
38 }
39 size_t * canaryLocation =
40 (size_t *) ((uintptr_tcxx . . $ uintptr_t#) ptr + realSize - sizeof(size_t));
41 *canaryLocation = (size_t) CANARYcxx . . $ HL/DebugHeap#CANARY.;
42 return ptr;
43 }
44
45 // Fill with F's.
46 inline void freecxx . . $ HL/DebugHeap#free(5d22bdacc48458e8). (void * ptr) {
47 if (ptr) {
48 size_t realSize = Super::getSize(ptr);
49 // Check for the canary.
50 size_t * canaryLocation =
51 (size_t *) ((uintptr_tcxx . . $ uintptr_t#) ptr + realSize - sizeof(size_t));
52 size_t storedCanary = *canaryLocation;
53 if (storedCanary != CANARYcxx . . $ HL/DebugHeap#CANARY.) {
54 abortcxx . . $ abort(8df32a62017fbbf6).();
55 }
56 for (unsigned int i = 0; i < realSize; i++) {
57 ((char *) ptr)[i] = freeChar;
58 }
59 Super::free (ptr);
60 }
61 }
62 };
63
64 }
65
66 #endif