Commit 8a798bf9 authored by Guido Casati's avatar Guido Casati Committed by Guido Casati

Refactor itti_malloc to use calloc_or_fail

Manual calloc + AssertFatal is replaced by calloc_or_fail, which
provides better error messages and calls abort().
Signed-off-by: default avatarGuido Casati <guido.casati@openairinterface.org>
parent a9bbda25
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
extern "C" { extern "C" {
#include <intertask_interface.h> #include <intertask_interface.h>
#include <common/utils/system.h> #include <common/utils/system.h>
#include <common/utils/utils.h>
#include "executables/softmodem-common.h" #include "executables/softmodem-common.h"
typedef struct timer_elm_s { typedef struct timer_elm_s {
...@@ -40,11 +41,11 @@ typedef struct timer_elm_s { ...@@ -40,11 +41,11 @@ typedef struct timer_elm_s {
static int nb_queues=0; static int nb_queues=0;
static pthread_mutex_t lock_nb_queues; static pthread_mutex_t lock_nb_queues;
void *itti_malloc(task_id_t origin_task_id, task_id_t destination_task_id, ssize_t size) { void *itti_malloc(task_id_t origin_task_id, task_id_t destination_task_id, ssize_t size)
void *ptr = NULL; {
AssertFatal ((ptr=calloc (size, 1)) != NULL, "Memory allocation of %zu bytes failed (%d -> %d)!\n", UNUSED(origin_task_id);
size, origin_task_id, destination_task_id); UNUSED(destination_task_id);
return ptr; return calloc_or_fail(1, size);
} }
int itti_free(task_id_t task_id, void *ptr) { int itti_free(task_id_t task_id, void *ptr) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment