mirror of https://github.com/PentHertz/srsLTE.git
adt pool - replace uint8_t* for void* to represent memory blocks
This commit is contained in:
parent
a79ca92020
commit
2fc2280c3b
|
@ -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<uint8_t*>(stack.try_pop());
|
||||
while (block != nullptr) {
|
||||
delete[] block;
|
||||
block = stack.try_pop();
|
||||
block = static_cast<uint8_t*>(stack.try_pop());
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -119,7 +119,7 @@ public:
|
|||
{
|
||||
assert(sz == sizeof(T));
|
||||
std::lock_guard<std::mutex> lock(mutex);
|
||||
uint8_t* block = obj_cache.try_pop();
|
||||
void* block = obj_cache.try_pop();
|
||||
|
||||
if (block != nullptr) {
|
||||
// allocation successful
|
||||
|
|
|
@ -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<void*>(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<std::mutex> lock(mutex);
|
||||
uint8_t* block = stack.try_pop();
|
||||
void* block = stack.try_pop();
|
||||
return block;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue