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

- Adjusting the code with the coding style.
master
AlaiaL 4 years ago committed by AlaiaL
parent f1cd4b1f0d
commit 9c764c299d

@ -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;

@ -123,11 +123,10 @@ 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))
{
stack_logger.error("Couldn't initialize MAC");
return SRSLTE_ERROR;
}
if (!mac.init(args.mac, rrc_cfg.cell_list, phy, &rlc, &rrc, mac_log)) {
stack_logger.error("Couldn't initialize MAC");
return SRSLTE_ERROR;
}
rlc.init(&pdcp, &rrc, &mac, task_sched.get_timer_handler());
pdcp.init(&rlc, &rrc, &gtpu);
rrc.init(rrc_cfg, phy, &mac, &rlc, &pdcp, &s1ap, &gtpu);

@ -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;
}
// Pre-alloc UE objects for first attaching users
prealloc_ue(10);
detected_rachs.resize(cells.size());
@ -815,9 +810,9 @@ int mac::get_mch_sched(uint32_t tti, bool is_mcch, dl_sched_list_t& dl_sched_res
int requested_bytes = (mcs_data.tbs / 8 > (int)mch.mtch_sched[mtch_index].lcid_buffer_size)
? (mch.mtch_sched[mtch_index].lcid_buffer_size)
: ((mcs_data.tbs / 8) - 2);
int bytes_received = ue_db[SRSLTE_MRNTI]->read_pdu(current_lcid, mtch_payload_buffer, requested_bytes);
mch.pdu[0].lcid = current_lcid;
mch.pdu[0].nbytes = bytes_received;
int bytes_received = ue_db[SRSLTE_MRNTI]->read_pdu(current_lcid, mtch_payload_buffer, requested_bytes);
mch.pdu[0].lcid = current_lcid;
mch.pdu[0].nbytes = bytes_received;
mch.mtch_sched[0].mtch_payload = mtch_payload_buffer;
dl_sched_res->pdsch[0].dci.rnti = SRSLTE_MRNTI;
if (bytes_received) {
@ -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;

Loading…
Cancel
Save