util.h (470B)
1 /* See LICENSE file for copyright and license details. */ 2 3 #ifndef UTIL_H 4 #define UTIL_H 5 6 #include <stddef.h> 7 8 /* Memory allocation with error handling */ 9 void *xmalloc(size_t size); 10 void *xrealloc(void *ptr, size_t size); 11 char *xstrdup(const char *s); 12 13 /* String utilities */ 14 char *str_trim(char *str); 15 int str_starts_with(const char *str, const char *prefix); 16 17 /* Error handling */ 18 void die(const char *fmt, ...); 19 void warn(const char *fmt, ...); 20 21 #endif /* UTIL_H */