-#include <assert.h>
+#include "system/stacktrace.h"
#include <stdlib.h>
-#include <SDL2/SDL.h>
+#include <SDL.h>
#include "color.h"
#include "game/sprite_font.h"
#include "console_log.h"
#include "math/point.h"
-#include "str.h"
-#include "system/error.h"
+#include "system/str.h"
#include "system/lt.h"
#include "system/nth_alloc.h"
size_t capacity)
{
Lt *lt = create_lt();
- if (lt == NULL) {
- return NULL;
- }
- Console_Log *console_log = PUSH_LT(lt, nth_alloc(sizeof(Console_Log)), free);
+ Console_Log *console_log = PUSH_LT(lt, nth_calloc(1, sizeof(Console_Log)), free);
if (console_log == NULL) {
- throw_error(ERROR_TYPE_LIBC);
RETURN_LT(lt, NULL);
}
console_log->lt = lt;
console_log->font_size = font_size;
console_log->capacity = capacity;
- console_log->buffer = PUSH_LT(lt, calloc(capacity, sizeof(char*)), free);
+ console_log->buffer = PUSH_LT(lt, nth_calloc(capacity, sizeof(char*)), free);
if (console_log->buffer == NULL) {
- throw_error(ERROR_TYPE_LIBC);
RETURN_LT(lt, NULL);
}
- console_log->colors = PUSH_LT(lt, calloc(capacity, sizeof(Color)), free);
+ console_log->colors = PUSH_LT(lt, nth_calloc(capacity, sizeof(Color)), free);
if (console_log->colors == NULL) {
- throw_error(ERROR_TYPE_LIBC);
RETURN_LT(lt, NULL);
}
void destroy_console_log(Console_Log *console_log)
{
- assert(console_log);
+ trace_assert(console_log);
for (size_t i = 0; i < console_log->capacity; ++i) {
if (console_log->buffer[i]) {
free(console_log->buffer[i]);
SDL_Renderer *renderer,
Point position)
{
- assert(console_log);
- assert(renderer);
+ trace_assert(console_log);
+ trace_assert(renderer);
(void) position;
for (size_t i = 0; i < console_log->capacity; ++i) {
int console_log_push_line(Console_Log *console_log, const char *line, Color color)
{
- assert(console_log);
- assert(line);
+ trace_assert(console_log);
+ trace_assert(line);
const size_t next_cursor = (console_log->cursor + 1) % console_log->capacity;