UE: factorize calloc() calls and exit on failure
This commit is contained in:
@@ -59,6 +59,7 @@ Description Defines EMM procedures executed by the Non-Access Stratum
|
||||
|
||||
#include "emm_proc.h"
|
||||
#include "nas_log.h"
|
||||
#include "utils.h"
|
||||
|
||||
#include "emm_sap.h"
|
||||
|
||||
@@ -106,11 +107,7 @@ static IdleMode_callback_t _emm_indication_notify;
|
||||
***************************************************************************/
|
||||
void IdleMode_initialize(nas_user_t *user, IdleMode_callback_t cb)
|
||||
{
|
||||
emm_plmn_list_t *emm_plmn_list = calloc(1, sizeof(emm_plmn_list_t));
|
||||
if ( emm_plmn_list == NULL ) {
|
||||
LOG_TRACE(ERROR, "EMM - Can't alloc emm_plmn_list");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
emm_plmn_list_t *emm_plmn_list = calloc_or_fail( sizeof(emm_plmn_list_t));
|
||||
user->emm_plmn_list = emm_plmn_list;
|
||||
/* Initialize the list of available PLMNs */
|
||||
emm_plmn_list->n_plmns = 0;
|
||||
|
||||
@@ -39,6 +39,7 @@ Description Defines the EPS Mobility Management procedure call manager,
|
||||
|
||||
#include "emm_main.h"
|
||||
#include "nas_log.h"
|
||||
#include "utils.h"
|
||||
#include "emmData.h"
|
||||
#include "MobileIdentity.h"
|
||||
#include "emm_proc_defs.h"
|
||||
@@ -134,11 +135,7 @@ void _emm_detach_initialize(emm_detach_data_t *emm_detach) {
|
||||
void emm_main_initialize(nas_user_t *user, emm_indication_callback_t cb, const char *imei)
|
||||
{
|
||||
LOG_FUNC_IN;
|
||||
user->emm_data = calloc(1, sizeof(emm_data_t));
|
||||
if ( user->emm_data == NULL ) {
|
||||
LOG_TRACE(ERROR, "EMM-MAIN - Failed to get allocate emm_data");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
user->emm_data = calloc_or_fail(sizeof(emm_data_t));
|
||||
/* USIM validity indicator */
|
||||
user->emm_data->usim_is_valid = FALSE;
|
||||
/* The IMEI read from the UE's non-volatile memory */
|
||||
@@ -397,31 +394,19 @@ void emm_main_initialize(nas_user_t *user, emm_indication_callback_t cb, const c
|
||||
/*
|
||||
* Initialize EMM timers
|
||||
*/
|
||||
user->emm_data->emm_timers = calloc(1, sizeof(emm_timers_t));
|
||||
if ( user->emm_data->emm_timers == NULL ) {
|
||||
LOG_TRACE(ERROR, "EMM-MAIN - Failed to alloc emm_timers");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
user->emm_data->emm_timers = calloc_or_fail(sizeof(emm_timers_t));
|
||||
_emm_timers_initialize(user->emm_data->emm_timers);
|
||||
|
||||
/*
|
||||
* Initialize Internal data used for detach procedure
|
||||
*/
|
||||
user->emm_data->emm_detach_data = calloc(1, sizeof(emm_detach_data_t));
|
||||
if ( user->emm_data->emm_detach_data == NULL ) {
|
||||
LOG_TRACE(ERROR, "EMM-MAIN - Failed to alloc emm_timers");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
user->emm_data->emm_detach_data = calloc_or_fail(sizeof(emm_detach_data_t));
|
||||
_emm_detach_initialize(user->emm_data->emm_detach_data);
|
||||
|
||||
/*
|
||||
* Initialize Internal data used for attach procedure
|
||||
*/
|
||||
user->emm_data->emm_attach_data = calloc(1, sizeof(emm_attach_data_t));
|
||||
if ( user->emm_data->emm_attach_data == NULL ) {
|
||||
LOG_TRACE(ERROR, "EMM-MAIN - Failed to alloc emm_timers");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
user->emm_data->emm_attach_data = calloc_or_fail(sizeof(emm_attach_data_t));
|
||||
_emm_attach_initialize(user->emm_data->emm_attach_data);
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user