summaryrefslogtreecommitdiff
path: root/src/shared.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/shared.h')
-rw-r--r--src/shared.h8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/shared.h b/src/shared.h
index 718bbf2..7d2db27 100644
--- a/src/shared.h
+++ b/src/shared.h
@@ -29,14 +29,16 @@
29 exit(EXIT_FAILURE); /* Makes gcc happy */\ 29 exit(EXIT_FAILURE); /* Makes gcc happy */\
30} while (0) 30} while (0)
31 31
32#define ERROR(status, errnum, format, ...) do {error((status), (errnum), (format)__VA_ARGS__); exit((status));} while (0)
33
32// `malloc()` with error checking. Calls `exit()` or `abort()` on error, depending on the value of `___VXGG___XALLOC_EXIT_ON_ERROR___` 34// `malloc()` with error checking. Calls `exit()` or `abort()` on error, depending on the value of `___VXGG___XALLOC_EXIT_ON_ERROR___`
33void * xmalloc(size_t size); 35void * xmalloc(size_t size);
34 36
35// `calloc()` with error checking. Calls `exit()` or `abort()` on error, depending on the value of `___VXGG___XALLOC_EXIT_ON_ERROR___` 37// `calloc()` with error checking. Calls `exit()` or `abort()` on error, depending on the value of `___VXGG___XALLOC_EXIT_ON_ERROR___`
36void* xcalloc(size_t nmemb, size_t size); 38void * xcalloc(size_t nmemb, size_t size);
37 39
38// `reallocarray()` with error checking. Calls `exit()` or `abort()` on error, depending on the value of `___VXGG___XALLOC_EXIT_ON_ERROR___` 40// `reallocarray()` with error checking. Calls `exit()` or `abort()` on error, depending on the value of `___VXGG___XALLOC_EXIT_ON_ERROR___`
39void* xreallocarray(void *ptr, size_t nmemb, size_t size); 41void * xreallocarray(void *ptr, size_t nmemb, size_t size);
40 42
41// Read the entire contents of a file descriptor into a malloc()'ed buffer 43// Read the entire contents of a file descriptor into a malloc()'ed buffer
42int rwbuf(char **str, unsigned long int initsize, int fd); 44int rwbuf(char **str, unsigned long int initsize, int fd);
@@ -45,6 +47,6 @@ int rwbuf(char **str, unsigned long int initsize, int fd);
45int wwbuf(int fd, const unsigned char *buf, int len); 47int wwbuf(int fd, const unsigned char *buf, int len);
46 48
47// `dirname()` reimplementation that returns a malloc()'ed string. According to the `x___` naming scheme, exits/aborts on alloc error. 49// `dirname()` reimplementation that returns a malloc()'ed string. According to the `x___` naming scheme, exits/aborts on alloc error.
48char *xdirname(const char * const path); 50char * xdirname(const char * const path);
49 51
50#endif \ No newline at end of file 52#endif \ No newline at end of file