made context statically allocated

This commit is contained in:
Luka Jankovic 2025-07-01 23:53:16 +02:00
parent b2a5ede334
commit d41e801aeb
3 changed files with 10 additions and 14 deletions

View file

@ -18,22 +18,17 @@
#include "kubo_context.h"
struct kubo_context *kubo_context_init() {
struct kubo_context *context = malloc(sizeof(struct kubo_context));
void kubo_context_init(struct kubo_context *context) {
if (!context) {
return NULL;
return;
}
kubo_wall_arr_init(&context->walls);
context->wall_select_index = 0;
return context;
}
void kubo_context_cleanup(struct kubo_context *context) {
kubo_wall_arr_free(&context->walls);
free(context);
}
void kubo_context_set_state(struct kubo_context *context,

View file

@ -46,7 +46,7 @@ struct kubo_context {
size_t wall_select_index;
};
struct kubo_context *kubo_context_init();
void kubo_context_init(struct kubo_context *context);
void kubo_context_cleanup(struct kubo_context *context);
void kubo_context_set_state(struct kubo_context *context,

13
main.c
View file

@ -6,16 +6,17 @@
int main(int argc, char *argv[]) {
struct kubo_context *context = kubo_context_init();
struct kubo_context context;
kubo_context_init(&context);
kubo_window_init(context);
kubo_window_init(&context);
while (!kubo_window_should_close(context)) {
kubo_window_tick(context);
while (!kubo_window_should_close(&context)) {
kubo_window_tick(&context);
}
kubo_window_cleanup(context);
kubo_context_cleanup(context);
kubo_window_cleanup(&context);
kubo_context_cleanup(&context);
return 0;
}