add assert to ensure a valid ptr is passed to memory pool deallocator

master
Francisco 4 years ago committed by Francisco Paisana
parent 20928651c7
commit 6159cb3817

@ -254,6 +254,7 @@ public:
void deallocate_node(void* p) void deallocate_node(void* p)
{ {
std::lock_guard<std::mutex> lock(mutex); std::lock_guard<std::mutex> lock(mutex);
assert(p != nullptr);
if (p != nullptr) { if (p != nullptr) {
obj_cache.push(static_cast<uint8_t*>(p)); obj_cache.push(static_cast<uint8_t*>(p));
} }

@ -18,7 +18,6 @@
#include "rrc_metrics.h" #include "rrc_metrics.h"
#include "srsenb/hdr/stack/upper/common_enb.h" #include "srsenb/hdr/stack/upper/common_enb.h"
#include "srslte/adt/circular_buffer.h" #include "srslte/adt/circular_buffer.h"
#include "srslte/adt/mem_pool.h"
#include "srslte/common/buffer_pool.h" #include "srslte/common/buffer_pool.h"
#include "srslte/common/common.h" #include "srslte/common/common.h"
#include "srslte/common/stack_procedure.h" #include "srslte/common/stack_procedure.h"

@ -15,6 +15,7 @@
#include "mac_controller.h" #include "mac_controller.h"
#include "rrc.h" #include "rrc.h"
#include "srslte/adt/mem_pool.h"
#include "srslte/interfaces/enb_phy_interfaces.h" #include "srslte/interfaces/enb_phy_interfaces.h"
#include "srslte/interfaces/pdcp_interface_types.h" #include "srslte/interfaces/pdcp_interface_types.h"
@ -119,7 +120,8 @@ public:
void operator delete(void* ptr)noexcept; void operator delete(void* ptr)noexcept;
void operator delete[](void* ptr) = delete; void operator delete[](void* ptr) = delete;
static srslte::background_allocator_obj_pool<ue, 16, 4>* get_ue_pool(); using ue_pool_t = srslte::background_allocator_obj_pool<ue, 16, 4>;
static ue_pool_t* get_ue_pool();
private: private:
// args // args

@ -67,7 +67,7 @@ srslte::background_allocator_obj_pool<rrc::ue, 16, 4>* rrc::ue::get_ue_pool()
{ {
// Note: batch allocation is going to be explicitly called in enb class construction. The pool object, therefore, // Note: batch allocation is going to be explicitly called in enb class construction. The pool object, therefore,
// will only be initialized if we instantiate an eNB // will only be initialized if we instantiate an eNB
static srslte::background_allocator_obj_pool<rrc::ue, 16, 4> ue_pool(true); static rrc::ue::ue_pool_t ue_pool(true);
return &ue_pool; return &ue_pool;
} }

Loading…
Cancel
Save