- Removed the try/catch. Checking the allocation with std::nothrow

- Adjusting the code with the coding style.
This commit is contained in:
AlaiaL 2021-02-03 18:14:36 +01:00 committed by AlaiaL
parent f1cd4b1f0d
commit 9c764c299d
3 changed files with 14 additions and 17 deletions

View File

@ -53,7 +53,11 @@ public:
pthread_mutex_init(&mutex, nullptr);
pthread_cond_init(&cv_not_empty, nullptr);
for (uint32_t i = 0; i < nof_buffers; i++) {
buffer_t* b = new buffer_t;
buffer_t* b = new (std::nothrow) buffer_t;
if (!b) {
perror("Error allocating memory. Exiting...\n");
exit(-1);
}
available.push(b);
}
capacity = nof_buffers;

View File

@ -123,8 +123,7 @@ int enb_stack_lte::init(const stack_args_t& args_, const rrc_cfg_t& rrc_cfg_)
sync_task_queue = task_sched.make_task_queue(args.sync_queue_size);
// Init all layers
if (! mac.init(args.mac, rrc_cfg.cell_list, phy, &rlc, &rrc, mac_log))
{
if (!mac.init(args.mac, rrc_cfg.cell_list, phy, &rlc, &rrc, mac_log)) {
stack_logger.error("Couldn't initialize MAC");
return SRSLTE_ERROR;
}

View File

@ -79,13 +79,8 @@ bool mac::init(const mac_args_t& args_,
reset();
try {
// Pre-alloc UE objects for first attaching users
prealloc_ue(10);
}catch(const std::bad_alloc& e){
perror("Error allocating data during the ue prealloc");
return false;
}
detected_rachs.resize(cells.size());
@ -904,7 +899,6 @@ int mac::get_ul_sched(uint32_t tti_tx_ul, ul_sched_list_t& ul_sched_res_list)
phy_ul_sched_res->nof_grants = 0;
int n = 0;
for (uint32_t i = 0; i < sched_result.nof_dci_elems; i++) {
if (sched_result.pusch[i].tbs > 0) {
// Get UE
uint16_t rnti = sched_result.pusch[i].dci.rnti;