~kris/hacks

sparser

ref: 83b1653b13073ba220e9836d46fa0054d7ee65c3 sparser/util.h -rw-r--r-- 526 bytes
83b1653b — Kris Yotam add README.md 5 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 */