made context statically allocated
This commit is contained in:
parent
b2a5ede334
commit
d41e801aeb
3 changed files with 10 additions and 14 deletions
|
|
@ -18,22 +18,17 @@
|
||||||
|
|
||||||
#include "kubo_context.h"
|
#include "kubo_context.h"
|
||||||
|
|
||||||
struct kubo_context *kubo_context_init() {
|
void kubo_context_init(struct kubo_context *context) {
|
||||||
struct kubo_context *context = malloc(sizeof(struct kubo_context));
|
|
||||||
if (!context) {
|
if (!context) {
|
||||||
return NULL;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
kubo_wall_arr_init(&context->walls);
|
kubo_wall_arr_init(&context->walls);
|
||||||
|
|
||||||
context->wall_select_index = 0;
|
context->wall_select_index = 0;
|
||||||
|
|
||||||
return context;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void kubo_context_cleanup(struct kubo_context *context) {
|
void kubo_context_cleanup(struct kubo_context *context) {
|
||||||
kubo_wall_arr_free(&context->walls);
|
kubo_wall_arr_free(&context->walls);
|
||||||
free(context);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void kubo_context_set_state(struct kubo_context *context,
|
void kubo_context_set_state(struct kubo_context *context,
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,7 @@ struct kubo_context {
|
||||||
size_t wall_select_index;
|
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_cleanup(struct kubo_context *context);
|
||||||
|
|
||||||
void kubo_context_set_state(struct kubo_context *context,
|
void kubo_context_set_state(struct kubo_context *context,
|
||||||
|
|
|
||||||
13
main.c
13
main.c
|
|
@ -6,16 +6,17 @@
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
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)) {
|
while (!kubo_window_should_close(&context)) {
|
||||||
kubo_window_tick(context);
|
kubo_window_tick(&context);
|
||||||
}
|
}
|
||||||
|
|
||||||
kubo_window_cleanup(context);
|
kubo_window_cleanup(&context);
|
||||||
kubo_context_cleanup(context);
|
kubo_context_cleanup(&context);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue