bbbe69d73c
Moved stuff around. Create an entry point for RSE. Created base for events module Signed-off-by: Piotr Krygier <piotrkrygier@everyonecancode@xyz>
55 lines
1.3 KiB
C
55 lines
1.3 KiB
C
/**
|
|
* @file commons.h
|
|
* @author Piotr Krygier (everyonecancode@gmail.com)
|
|
* @brief Common functionality for all modules
|
|
* @version 0.1
|
|
* @date 2023-10-05
|
|
*
|
|
* @copyright Copyright (c) 2023
|
|
*
|
|
*/
|
|
|
|
#ifndef COMMONS_H
|
|
#define COMMONS_H
|
|
|
|
#include <SDL3/SDL_log.h>
|
|
#include <stdint.h>
|
|
#include <stdlib.h>
|
|
|
|
/**
|
|
* @brief Macro for allocating memory and checking it on the same line
|
|
*
|
|
*/
|
|
#ifndef RSE_TEST
|
|
#define rse_malloc(ptr, size) \
|
|
ptr = calloc(1, size); \
|
|
if (ptr == NULL) { \
|
|
SDL_LogCritical(SDL_LOG_CATEGORY_APPLICATION, "Memory allocation failure"); \
|
|
exit(1); \
|
|
}
|
|
|
|
#define rse_free(ptr) free(ptr);
|
|
|
|
#define rse_memcpy(dst, src, size) memcpy(dst, src, size);
|
|
#define rse_memset(ptr, value, size) memset(ptr, value, size);
|
|
#else
|
|
#define rse_malloc(ptr, size) ptr = NULL;
|
|
#define rse_free(ptr)
|
|
#define rse_memcpy(dst, src, size)
|
|
#define rse_memset
|
|
#endif
|
|
|
|
/**
|
|
* @brief Error type for RSE
|
|
*
|
|
*/
|
|
typedef uint32_t rse_err_t;
|
|
|
|
/**
|
|
* @brief General type for ID use
|
|
*
|
|
*/
|
|
typedef uint32_t rse_id_t;
|
|
|
|
#endif /* COMMONS_H */
|