Skip to content

Commit

Permalink
fix blocksize
Browse files Browse the repository at this point in the history
  • Loading branch information
bertmelis authored May 14, 2024
1 parent 9bece23 commit 74b9215
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/MemoryPool/src/Fixed.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class Fixed {
: _buffer{0}
, _head(_buffer) {
unsigned char* b = _head;
std::size_t adjustedBlocksize = sizeof(sizeof(unsigned char*)) > sizeof(blocksize) ? sizeof(sizeof(unsigned char*)) : sizeof(blocksize);
std::size_t adjustedBlocksize = sizeof(std::size_t) > blocksize ? sizeof(std::size_t) : blocksize;
for (std::size_t i = 0; i < nrBlocks - 1; ++i) {
*reinterpret_cast<unsigned char**>(b) = b + adjustedBlocksize;
b += adjustedBlocksize;
Expand Down Expand Up @@ -67,7 +67,7 @@ class Fixed {

#ifdef MEMPOL_DEBUG
void print() {
std::size_t adjustedBlocksize = sizeof(sizeof(unsigned char*)) > sizeof(blocksize) ? sizeof(sizeof(unsigned char*)) : sizeof(blocksize);
std::size_t adjustedBlocksize = sizeof(std::size_t) > blocksize ? sizeof(std::size_t) : blocksize;
std::cout << "+--------------------" << std::endl;
std::cout << "|start:" << reinterpret_cast<void*>(_buffer) << std::endl;
std::cout << "|blocks:" << nrBlocks << std::endl;
Expand Down Expand Up @@ -99,7 +99,7 @@ class Fixed {
#endif

private:
unsigned char _buffer[nrBlocks * (sizeof(sizeof(unsigned char*)) > sizeof(blocksize) ? sizeof(sizeof(unsigned char*)) : sizeof(blocksize))];
unsigned char _buffer[nrBlocks * (sizeof(std::size_t) > blocksize ? sizeof(std::size_t) : blocksize)];
unsigned char* _head;
std::mutex _mutex;
};
Expand Down

0 comments on commit 74b9215

Please sign in to comment.