#include "kubo_context.h" struct kubo_context *kubo_context_init() { struct kubo_context *context = malloc(sizeof(struct kubo_context)); if (!context) { return NULL; } kubo_wall_arr_init(&context->walls); return context; } void kubo_context_cleanup(struct kubo_context *context) { kubo_wall_arr_free(&context->walls); free(context); } struct kubo_wall *kubo_context_get_pending_wall(struct kubo_context *context) { if (context->walls.count > 0) { struct kubo_wall *last_wall = kubo_wall_arr_get(&context->walls, context->walls.count - 1); switch (last_wall->state) { case KUBO_WALL_INIT: case KUBO_WALL_DRAWING: return last_wall; break; default: break; } } struct kubo_wall *wall = kubo_wall_init(); kubo_wall_arr_add(&context->walls, wall); return wall; }