Debian Codegraph @

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

raw symbols SCIP
1 // -*- C++ -*-cxx . . $ `<file>/vendor/Heap-Layers/heaps/debug/checkheap.h`/
2
3 #ifndef HL_CHECKHEAP_H
4 #define HL_CHECKHEAP_Hcxx . . $ `vendor/Heap-Layers/heaps/debug/checkheap.h:4:9`!
5
6 #include <cstring>
7
8 #include <assert.h>
9 #include <stdio.h>
10 #include <stdlib.h>
11
12 /**
13 * @class CheckHeap
14 * @brief Performs simple checks on memory allocations.
15 *
16 **/
17
18 namespace HLcxx . . $ HL/ {
19
20 template <class SuperHeap>
21 class CheckHeapcxx . . $ HL/CheckHeap# : public SuperHeap {
22 private:
23
24 enumcxx . . $ HL/CheckHeap#$anonymous_type_0# { RECEIVED_A_NULL_OBJECT_FROM_MALLOCcxx . . $ HL/CheckHeap#RECEIVED_A_NULL_OBJECT_FROM_MALLOC. = 0 };
25 enumcxx . . $ HL/CheckHeap#$anonymous_type_1# { RECEIVED_AN_UNALIGNED_OBJECT_FROM_MALLOCcxx . . $ HL/CheckHeap#RECEIVED_AN_UNALIGNED_OBJECT_FROM_MALLOC. = 0 };
26
27 public:
28
29 inline void * malloccxx . . $ HL/CheckHeap#malloc(bfcfa4d6b7f7ef64). (size_t sz) {
30 void * addr = SuperHeap::malloc (sz);
31 #if !defined(NDEBUGcxx . . $ `<built-in>:458:9`!)
32
33 // Check for null (this should in general not happen).
34 if (addr == NULL) {
35 assert (RECEIVED_A_NULL_OBJECT_FROM_MALLOC);
36 printf ("RECEIVED_A_NULL_OBJECT_FROM_MALLOC\n");
37 abort();
38 }
39 // Ensure object size is correct.
40 assert (SuperHeap::getSize(addr) >= sz);
41
42 // Check alignment.
43 if ((unsigned long) addr % SuperHeap::Alignment != 0) {
44 assert (RECEIVED_AN_UNALIGNED_OBJECT_FROM_MALLOC);
45 printf ("RECEIVED_AN_UNALIGNED_OBJECT_FROM_MALLOC\n");
46 abort();
47 }
48
49 // Wipe out the old contents.
50 std::memset (addr, 0, SuperHeap::getSize(addr));
51 #endif
52 return addr;
53 }
54
55 inline void freecxx . . $ HL/CheckHeap#free(5d22bdacc48458e8). (void * ptr) {
56 #if !defined(NDEBUGcxx . . $ `<built-in>:458:9`!)
57 // Wipe out the old contents.
58 std::memset (ptr, 0, SuperHeap::getSize(ptr));
59 #endif
60 SuperHeap::free (ptr);
61 }
62
63 };
64
65 }
66
67 #endif