Files

24 lines
515 B
C
Raw Permalink Normal View History

2026-05-24 23:24:25 -07:00
#ifndef INCLUDED_UTIL_H
#define INCLUDED_UTIL_H
2026-05-25 17:25:50 -07:00
#include <stddef.h>
2026-05-24 23:24:25 -07:00
#if __has_attribute(format)
2026-05-25 21:59:56 -07:00
#define PRINTF_LIKE(i, j) __attribute__((format(printf, i, j)))
2026-05-24 23:24:25 -07:00
#else
2026-05-25 21:59:56 -07:00
#define PRINTF_LIKE(i, j)
2026-05-24 23:24:25 -07:00
#endif
2026-05-25 17:25:50 -07:00
void *realloc_safe(void *oldptr, size_t size);
void *malloc_safe(size_t size);
2026-05-24 23:24:25 -07:00
2026-05-25 17:25:50 -07:00
// asprintf is not POSIX
PRINTF_LIKE(2, 3)
int alloc_sprintf(char *restrict *restrict out, const char *restrict fmt, ...);
2026-05-24 23:24:25 -07:00
PRINTF_LIKE(1, 2)
2026-05-25 17:25:50 -07:00
void log_error(const char *restrict fmt, ...);
void log_errno(const char *detail);
2026-05-24 23:24:25 -07:00
#endif