@@ -27,29 +27,28 @@ struct MemoryPool::MemoryPoolImpl
27
27
28
28
static const ConfigSet::Entry s_configdata[];
29
29
30
- template <typename T>
31
30
struct Chunk {
32
- T* ptr;
31
+ unsigned char * ptr;
33
32
size_t wmark;
34
33
size_t size;
35
34
};
36
35
37
- ConfigSet m_config;
36
+ ConfigSet m_config;
38
37
39
- util::spinlock m_lock;
38
+ util::spinlock m_lock;
40
39
41
- vector< Chunk< uint64_t > > m_chunks;
42
- bool m_can_expand;
40
+ vector<Chunk> m_chunks;
41
+ bool m_can_expand;
43
42
44
- size_t m_total_reserved;
45
- size_t m_total_used;
43
+ size_t m_total_reserved;
44
+ size_t m_total_used;
46
45
47
46
// --- interface
48
47
49
48
void expand (size_t bytes) {
50
- size_t len = max (( bytes+ sizeof ( uint64_t )- 1 )/ sizeof ( uint64_t ) , chunksize);
49
+ size_t len = max (bytes, chunksize);
51
50
52
- uint64_t * ptr = new uint64_t [len];
51
+ unsigned char * ptr = new unsigned char [len];
53
52
std::fill_n (ptr, len, 0 );
54
53
55
54
m_chunks.push_back ( { ptr, 0 , len } );
@@ -58,7 +57,7 @@ struct MemoryPool::MemoryPoolImpl
58
57
}
59
58
60
59
void * allocate (size_t bytes, bool can_expand) {
61
- size_t n = ( bytes+ sizeof ( uint64_t )- 1 )/ sizeof ( uint64_t );
60
+ size_t n = bytes + ((bytes+ 7 )% 8 );
62
61
63
62
std::lock_guard<util::spinlock>
64
63
g (m_lock);
@@ -126,7 +125,7 @@ struct MemoryPool::MemoryPoolImpl
126
125
127
126
const ConfigSet::Entry MemoryPool::MemoryPoolImpl::s_configdata[] = {
128
127
// key, type, value, short description, long description
129
- { " pool_size" , CALI_TYPE_UINT, " 2097152 " ,
128
+ { " pool_size" , CALI_TYPE_UINT, " 1048576 " ,
130
129
" Initial size of the Caliper memory pool (in bytes)" ,
131
130
" Initial size of the Caliper memory pool (in bytes)"
132
131
},
0 commit comments