~kris/hacks

sparser

ref: 78c7f82812eacc253dec423b846d08590e9ee347 sparser/util.h -rw-r--r-- 526 bytes
78c7f828 — Kris Yotam convert README.md to README.txt 4 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
/* See LICENSE file for copyright and license details. */

#ifndef UTIL_H
#define UTIL_H

#include <stddef.h>

/* Memory allocation with error handling */
void *xmalloc(size_t size);
void *xrealloc(void *ptr, size_t size);
char *xstrdup(const char *s);

/* String utilities */
char *str_trim(char *str);
int str_starts_with(const char *str, const char *prefix);
int str_ends_with(const char *str, const char *suffix);

/* Error handling */
void die(const char *fmt, ...);
void warn(const char *fmt, ...);

#endif /* UTIL_H */