File tree 3 files changed +7
-4
lines changed
3 files changed +7
-4
lines changed Original file line number Diff line number Diff line change 26
26
#define SHARE_MEMORY_ALLOCATION_HPP
27
27
28
28
#include " memory/allStatic.hpp"
29
+ #include " utilities/debug.hpp"
29
30
#include " utilities/globalDefinitions.hpp"
30
31
#include " utilities/macros.hpp"
31
32
@@ -138,11 +139,13 @@ typedef AllocFailStrategy::AllocFailEnum AllocFailType;
138
139
/*
139
140
* Memory types
140
141
*/
141
- enum class MEMFLAGS {
142
+ enum class MEMFLAGS : uint8_t {
142
143
MEMORY_TYPES_DO (MEMORY_TYPE_DECLARE_ENUM)
143
144
mt_number_of_types // number of memory types (mtDontTrack
144
145
// is not included as validate type)
145
146
};
147
+ // Extra insurance that MEMFLAGS truly has the same size as uint8_t.
148
+ STATIC_ASSERT (sizeof (MEMFLAGS) == sizeof(uint8_t ));
146
149
147
150
#define MEMORY_TYPE_SHORTNAME (type, human_readable ) \
148
151
constexpr MEMFLAGS type = MEMFLAGS::type;
Original file line number Diff line number Diff line change @@ -92,7 +92,7 @@ class MallocHeader {
92
92
NOT_LP64 (uint32_t _alt_canary);
93
93
const size_t _size;
94
94
const uint32_t _mst_marker;
95
- const uint8_t _flags;
95
+ const MEMFLAGS _flags;
96
96
const uint8_t _unused;
97
97
uint16_t _canary;
98
98
@@ -119,7 +119,7 @@ class MallocHeader {
119
119
inline MallocHeader (size_t size, MEMFLAGS flags, uint32_t mst_marker);
120
120
121
121
inline size_t size () const { return _size; }
122
- inline MEMFLAGS flags () const { return (MEMFLAGS) _flags; }
122
+ inline MEMFLAGS flags () const { return _flags; }
123
123
inline uint32_t mst_marker () const { return _mst_marker; }
124
124
bool get_stack (NativeCallStack& stack) const ;
125
125
Original file line number Diff line number Diff line change 35
35
#include " utilities/nativeCallStack.hpp"
36
36
37
37
inline MallocHeader::MallocHeader (size_t size, MEMFLAGS flags, uint32_t mst_marker)
38
- : _size(size), _mst_marker(mst_marker), _flags(NMTUtil::flag_to_index( flags) ),
38
+ : _size(size), _mst_marker(mst_marker), _flags(flags),
39
39
_unused(0 ), _canary(_header_canary_life_mark)
40
40
{
41
41
assert (size < max_reasonable_malloc_size, " Too large allocation size?" );
You can’t perform that action at this time.
0 commit comments