#ifndef SMK_MALLOC_H
#define SMK_MALLOC_H
#include <stdlib.h>
#include <stdio.h>
#include <errno.h>
#include <string.h>
#define smk_assert(p) \
{ \
if (!p) \
{ \
fprintf(stderr, "libsmacker::smk_assert(" #p "): ERROR: NULL POINTER at line %lu, file %s\n", (unsigned long)__LINE__, __FILE__); \
goto error; \
} \
}
#define smk_free(p) \
{ \
if (p) \
{ \
free(p); \
p = NULL; \
} \
\
}
#define smk_malloc(p, x) \
{ \
\
p = calloc(1, x); \
if (!p) \
{ \
fprintf(stderr, "libsmacker::smk_malloc(" #p ", %lu) - ERROR: calloc() returned NULL (file: %s, line: %lu)\n\tReason: [%d] %s\n", \
(unsigned long) (x), __FILE__, (unsigned long)__LINE__, errno, strerror(errno)); \
exit(EXIT_FAILURE); \
} \
}
#endif