From 2fc2280c3b7521f8e08cd3677af6ca710650336f Mon Sep 17 00:00:00 2001 From: Francisco Date: Fri, 2 Apr 2021 14:00:50 +0100 Subject: [PATCH] adt pool - replace uint8_t* for void* to represent memory blocks --- lib/include/srsran/adt/pool/mem_pool.h | 8 ++++---- lib/include/srsran/adt/pool/memblock_cache.h | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/include/srsran/adt/pool/mem_pool.h b/lib/include/srsran/adt/pool/mem_pool.h index 028ea414c..07a7d3bca 100644 --- a/lib/include/srsran/adt/pool/mem_pool.h +++ b/lib/include/srsran/adt/pool/mem_pool.h @@ -48,7 +48,7 @@ public: { assert(sz == sizeof(T)); static const size_t blocksize = std::max(sizeof(T), memblock_cache::min_memblock_size()); - uint8_t* block = stack.try_pop(); + void* block = stack.try_pop(); if (block == nullptr) { block = new uint8_t[blocksize]; } @@ -75,10 +75,10 @@ public: void clear() { - uint8_t* block = stack.try_pop(); + uint8_t* block = static_cast(stack.try_pop()); while (block != nullptr) { delete[] block; - block = stack.try_pop(); + block = static_cast(stack.try_pop()); } } }; @@ -119,7 +119,7 @@ public: { assert(sz == sizeof(T)); std::lock_guard lock(mutex); - uint8_t* block = obj_cache.try_pop(); + void* block = obj_cache.try_pop(); if (block != nullptr) { // allocation successful diff --git a/lib/include/srsran/adt/pool/memblock_cache.h b/lib/include/srsran/adt/pool/memblock_cache.h index a0be95bdc..660f02aa2 100644 --- a/lib/include/srsran/adt/pool/memblock_cache.h +++ b/lib/include/srsran/adt/pool/memblock_cache.h @@ -50,7 +50,7 @@ public: count++; } - uint8_t* try_pop() noexcept + void* try_pop() noexcept { if (is_empty()) { return nullptr; @@ -58,7 +58,7 @@ public: node* last_head = head; head = head->prev; count--; - return (uint8_t*)last_head; + return static_cast(last_head); } bool is_empty() const { return head == nullptr; } @@ -113,10 +113,10 @@ public: } } - uint8_t* try_pop() noexcept + void* try_pop() noexcept { std::lock_guard lock(mutex); - uint8_t* block = stack.try_pop(); + void* block = stack.try_pop(); return block; }