diff options
| author | Andrew Chambers <[email protected]> | 2021-10-02 17:39:49 +1300 |
|---|---|---|
| committer | Andrew Chambers <[email protected]> | 2021-10-02 17:39:49 +1300 |
| commit | c4d9ffb4ca89c15295c375daea8eefce18ab4411 (patch) | |
| tree | 337b0201edde817293abf9fcf06d1417b7fec9e4 /minias.h | |
Initial commit.
Diffstat (limited to 'minias.h')
| -rw-r--r-- | minias.h | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/minias.h b/minias.h new file mode 100644 index 0000000..f694f79 --- /dev/null +++ b/minias.h @@ -0,0 +1,33 @@ +#include <elf.h> +#include <stddef.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> + +static void die(char *s) { + write(STDERR_FILENO, s, strlen(s)); + exit(1); +} + +static void *xcalloc(size_t nmemb, size_t n) { + void *p; + p = calloc(nmemb, n); + if (!p) + die("out of memory"); + return p; +} + +static void *xmalloc(size_t n) { + void *p; + p = malloc(n); + if (!p) + die("out of memory"); + return p; +} + +static void *xrealloc(void *p, size_t n) { + p = realloc(p, n); + if (!p) + die("out of memory"); + return p; +}
\ No newline at end of file |
