6 /* Misc. definitions. */
8 #define likely(x) __builtin_expect(!!(x), 1)
9 #define unlikely(x) __builtin_expect((x), 0)
12 checked_malloc(size_t size
, char *filename
, unsigned int line
, const char *func
)
14 void *p
= malloc(size
);
16 fprintf(stderr
, "%s:%u: %s: OUT OF MEMORY malloc(%zu)\n",
17 filename
, line
, func
, size
);
24 checked_calloc(size_t nmemb
, size_t size
, char *filename
, unsigned int line
, const char *func
)
26 void *p
= calloc(nmemb
, size
);
28 fprintf(stderr
, "%s:%u: %s: OUT OF MEMORY calloc(%zu, %zu)\n",
29 filename
, line
, func
, nmemb
, size
);
35 #define malloc2(size) checked_malloc((size), __FILE__, __LINE__, __func__)
36 #define calloc2(nmemb, size) checked_calloc((nmemb), (size), __FILE__, __LINE__, __func__)