Refactor project

Crealned up some TODOs, FIXMEs etc. Added better error handling. Looks
better, feels better.
This commit is contained in:
Piotr Krygier committed 2023-10-10 10:46:12 +02:00
1 parent bd4dd74881
commit 42dc4d6fcd
29 files changed
+750 -645

No files matched your search

+5 -5
View File
@@ -14,14 +14,14 @@
#include "localization.h"
#define vulkan_error_messages vulkan_error_messages_nolocale[SELECTED_LANGUAGE]
#define common_messages common_messages_nolocale[SELECTED_LANGUAGE]
enum vulkan_errors_t {
COMMON_MEMORY_ALLOCATION_FAILED,
LAST_MESSAGE
enum common_errors_t {
COMMON_ERROR_MEMORY_ALLOCATION_FAILED,
COMMON_ERROR_LAST_MESSAGE
};
static const char vulkan_error_messages_nolocale[LAST_LANGUAGE][LAST_MESSAGE][MAX_MESSAGE_LENGHT] = {
static const char common_messages_nolocale[LAST_LANGUAGE][COMMON_ERROR_LAST_MESSAGE][MAX_MESSAGE_LENGHT] = {
{/* EN_US */
/* COMMON_MEMORY_ALLOCATION_FAILED */
"Unable to allocate memory"
+2 -2
View File
@@ -34,7 +34,7 @@
* @brief Log level. Is not an enum class, because level is being compared to enable prints
*
*/
typedef enum
enum log_level_t
{
LOGLEVEL_TRACE,
LOGLEVEL_DEBUG,
@@ -42,7 +42,7 @@ typedef enum
LOGLEVEL_WARNING,
LOGLEVEL_ERROR,
LOGLEVEL_FATAL
} LogLevel;
};
void _log_log(unsigned int level, const char* file, int line, const char* fmt, ...);
+34
View File
@@ -0,0 +1,34 @@
/**
* @file rse_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 RSE_COMMONS_H
#define RSE_COMMONS_H
#include <stdint.h>
/**
* @brief Macro for allocating memory and checking it on the same line
*
*/
#define rse_malloc(ptr, size) \
ptr = malloc(size); \
if (ptr == NULL) { \
LOGF(common_messages[COMMON_ERROR_MEMORY_ALLOCATION_FAILED]); \
return RSE_COMMON_ERROR_MALLLOC_FAILED; \
}
/**
* @brief Error type for RSE
*
*/
typedef uint32_t rse_err_t;
#endif /* RSE_COMMONS_H */
+30
View File
@@ -0,0 +1,30 @@
/**
* @file rse_errors_common.h
* @author Piotr Krygier (everyonecancode@gmail.com)
* @brief Common error messages, that can appear in any module
* @version 0.1
* @date 2023-10-05
*
* @copyright Copyright (c) 2023
*
*/
#ifndef RSE_ERRORS_COMMON_H
/* Macro for checking status of function execution in initVulkan. Created to avoid writing boilerplate code */
#define STATUS_CHECK(FUNC) \
status = FUNC; \
if (RSE_ERROR_NO_ERROR != status) { \
return status; \
}
#define RSE_COMMON_MODULE_ID 0x0100U
enum rse_common_error_t
{
RSE_ERROR_NO_ERROR = RSE_COMMON_MODULE_ID,
RSE_COMMON_ERROR_MALLLOC_FAILED,
};
#define RSE_ERRORS_COMMON_H
#endif /* RSE_ERRORS_COMMON_H */