From 08fb644c7d101551edfe8fc2608e0ac501b3df9f Mon Sep 17 00:00:00 2001 From: "@syxhe" Date: Sun, 8 Jun 2025 17:25:13 -0500 Subject: Trim the fat --- src/shared.h | 26 +++++--------------------- 1 file changed, 5 insertions(+), 21 deletions(-) (limited to 'src/shared.h') diff --git a/src/shared.h b/src/shared.h index 0b401fe..efb95ad 100644 --- a/src/shared.h +++ b/src/shared.h @@ -32,26 +32,19 @@ typedef void (*fcallback)(void*); // free()-like callback signature exit(EXIT_FAILURE); /* Makes gcc happy */\ } while (0) -// Whether to use `XALLOC` or normal `malloc` functions for acquiring new memory via the `VALLOC()` macro. `> 0` -// enables XALLOC functionality -#define ___VXGG___USE_XALLOC_FOR_VALLOC___ 0 -#define VALLOC(nmemb, size) ((___VXGG___USE_XALLOC_FOR_VALLOC___ > 0) ? xmalloc((nmemb) * (size)) : malloc((nmemb) * (size))) + +#define VALLOC(nmemb, size) malloc((nmemb) * (size)) // Error macro that gcc will not complain about #define ERROR(status, errnum, format, ...) do {error((status), (errnum), (format)__VA_ARGS__); exit((status));} while (0) +#define WARN(errnum, format, ...) do {error(0, (errnum), (format)__VA_ARGS__);} while (0) -// `malloc()` with error checking. Calls `exit()` or `abort()` on error, depending on the value of `___VXGG___XALLOC_EXIT_ON_ERROR___` -void * xmalloc(size_t size); -// `calloc()` with error checking. Calls `exit()` or `abort()` on error, depending on the value of `___VXGG___XALLOC_EXIT_ON_ERROR___` -void * xcalloc(size_t nmemb, size_t size); -// `reallocarray()` with error checking. Calls `exit()` or `abort()` on error, depending on the value of `___VXGG___XALLOC_EXIT_ON_ERROR___` -void * xreallocarray(void *ptr, size_t nmemb, size_t size); // Read the entire contents of a file descriptor into a malloc()'ed buffer int rwbuf(char **str, unsigned long int initsize, int fd); // Write the entire contents of a buffer into a file descriptor int wwbuf(int fd, const unsigned char *buf, int len); -// `dirname()` reimplementation that returns a malloc()'ed string. According to the `x___` naming scheme, exits/aborts on alloc error. -char * xdirname(const char * const path); +// `dirname()` reimplementation that returns a malloc()'ed string +char * vxdirname(const char * const path); @@ -87,13 +80,4 @@ cleanup_init(&__CLEANUP, __CLEANUP_FUNCS, __CLEANUP_ARGS, (size)) #define cleanup_ERRORFLAGGED (__FLAG != 0) #define cleanup_CNDEXEC(code) while(!cleanup_ERRORFLAGGED) {code; break;} - - -// Generic task to be executed by a consumer -typedef struct task task; -// A queue of tasks -typedef struct taskqueue taskqueue; -// A concurrent queue of tasks, basically a threadpool tasks can be dispatched to -typedef struct ctqueue ctqueue; - #endif \ No newline at end of file -- cgit v1.2.3