diff --git a/kubo_context.c b/kubo_context.c index aaebc8c..be01f9a 100644 --- a/kubo_context.c +++ b/kubo_context.c @@ -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, diff --git a/kubo_context.h b/kubo_context.h index e8826d0..3e77518 100644 --- a/kubo_context.h +++ b/kubo_context.h @@ -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, diff --git a/main.c b/main.c index 60bde30..5592015 100644 --- a/main.c +++ b/main.c @@ -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; }