#include #include #include #include #include #include #include "raygui.h" #ifndef UTIL_H #define UTIL_H typedef struct Game Game; #define FT_NAMEMAX 256 // Memory management. #define FT_MALLOC(size) malloc(size) #define FT_CALLOC(nmemb, size) calloc(nmemb, size) #define FT_REALLOC(ptr, size) realloc(ptr, size) #define FT_REALLOCARRAY(ptr, nmemb, size) reallocarray(ptr, nmemb, size) //#define FT_REALLOCARRAY(ptr, nmemb, size) realloc(ptr, nmemb * size) #define FT_FREE(ptr) free(ptr) // Errors. #define ALLOCATION_ERROR TraceLog(LOG_ERROR, "Allocation error in %s:%d", \ __FILE__, __LINE__); typedef enum FTError { FTERROR = -1, FTSUCCESS = 0 } FTError; // Bit shit. #define SET_BIT(b, n) (b | (0x1 << n)) #define CLEAR_BIT(b, n) (b & ~(0x1 << n)) #define IS_BIT_SET(b, n) ((b >> n) & 0x1) #define TOGGLE_BIT(b, n) (b ^ (0x1 << n)) #define HAS_FLAG(v, f) ((v & f) == f) #endif