From 9edd12e87874eabdc74e45359a5228558e124c98 Mon Sep 17 00:00:00 2001 From: "@syxhe" Date: Thu, 8 Jan 2026 01:59:36 -0600 Subject: Add clay to project --- src/shared.c | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) (limited to 'src/shared.c') diff --git a/src/shared.c b/src/shared.c index 1dd0309..5e425f0 100644 --- a/src/shared.c +++ b/src/shared.c @@ -12,6 +12,30 @@ #ifndef __VXGG_REWRITE___SHARED_C___3880294315821___ #define __VXGG_REWRITE___SHARED_C___3880294315821___ 1 +#include +#include +#include +#include +#include + + +#define VXGG_MALLOC(size) malloc((size)) +#define VXGG_CALLOC(nmemb, size) calloc((nmemb), (size)) +#ifdef DEBUG +#undef VXGG_MALLOC +#undef VXGG_CALLOC + +void* VXGG_ALLOC(size_t size) { + void *mem = malloc(size); + if(!mem) return NULL; + memset(mem, 0x57, size); // VX -> {21, 23} % 16 -> 0x57 + return mem; +} + +#define VXGG_MALLOC(size) VXGG_ALLOC((size)) +#define VXGG_CALLOC(nmemb, size) VXGG_ALLOC((nmemb) * (size)) +#endif + #define STATIC_ARRAY_LEN(arr) (sizeof((arr))/sizeof((arr)[0])) #define ERRRET(errval, retval) do {\ @@ -40,17 +64,11 @@ #define ERROR(status, errnum, format, ...) do {error((status), (errnum), (format)__VA_ARGS__); exit((status));} while (0) //! Spit out a warning using `error` #define WARN(errnum, format, ...) do {error(0, (errnum), (format)__VA_ARGS__);} while (0) - +// TODO: gcc is yelling at me about these functions implicitly falling through. Not sure why typedef int (*gcallback)(void*); //!< Generic callback signature typedef void (*fcallback)(void*); //!< free()-like callback signature -#include -#include -#include -#include -#include - /** * @brief Read the entire contents of a file descriptor into a malloc()'ed buffer * -- cgit v1.2.3