24 lines
515 B
C
24 lines
515 B
C
#ifndef INCLUDED_UTIL_H
|
|
#define INCLUDED_UTIL_H
|
|
|
|
#include <stddef.h>
|
|
|
|
#if __has_attribute(format)
|
|
#define PRINTF_LIKE(i, j) __attribute__((format(printf, i, j)))
|
|
#else
|
|
#define PRINTF_LIKE(i, j)
|
|
#endif
|
|
|
|
void *realloc_safe(void *oldptr, size_t size);
|
|
void *malloc_safe(size_t size);
|
|
|
|
// asprintf is not POSIX
|
|
PRINTF_LIKE(2, 3)
|
|
int alloc_sprintf(char *restrict *restrict out, const char *restrict fmt, ...);
|
|
|
|
PRINTF_LIKE(1, 2)
|
|
void log_error(const char *restrict fmt, ...);
|
|
void log_errno(const char *detail);
|
|
|
|
#endif
|