Public feed
#727584
#ifndef _MALLOC_H_
#define _MALLOC_H_
#define __func__ __FUNCTION__
//memory allocation macro
//----------------------------
#define CALLOC(result, type, number) if (!((result) = (type *)calloc((number), sizeof(type)))) \
printf("SYS_ERR: calloc failure at %s:%d(%s).\n", __FILE__, __LINE__, __func__), exit(1)
#define REALLOC(result, type, number) if (!((result) = (type *)realloc((result), sizeof(type) * (number)))) \
printf("SYS_ERR: realloc failure at %s:%d(%s).\n", __FILE__, __LINE__, __func__), exit(1)
#define FREE(result) if (result) free(result), result = NULL
//null pointer macro check [Aier]
//----------------------------
//if null pointer found, then return
#define nullpo_ret(result, target) if (!(target)) return (result)
//critical null pointer failure, terminate program!
#define nullpo_chk(target) if (!(target)) \
printf("SYS_ERR: nullpo failure at %s:%d(%s).\n", __FILE__, __LINE__, __func__), exit(1)
#endif