From 48d48a1af3528a655c632d2da81d1aba9da8b8b8 Mon Sep 17 00:00:00 2001 From: Slade Getz Date: Thu, 25 May 2023 18:40:33 -0600 Subject: [PATCH] fixed some pointers by casting on frees --- src/animations.c | 8 ++++---- src/animations.h | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/animations.c b/src/animations.c index 9e79450..2596f99 100644 --- a/src/animations.c +++ b/src/animations.c @@ -35,7 +35,7 @@ static void matrix_init(struct term_buf* buf) { buf->init_width = buf->width; buf->init_height = buf->height; - buf->astate = malloc(sizeof(struct matrix_state)); + buf->astate = (struct matrix_state*)malloc(sizeof(struct matrix_state)); // cast state to matrix_state pointer struct matrix_state* s = (struct matrix_state*)buf->astate; @@ -117,7 +117,7 @@ static void matrix_free(struct term_buf* buf) free(((struct matrix_state*)buf->astate)->length); free(((struct matrix_state*)buf->astate)->spaces); free(((struct matrix_state*)buf->astate)->updates); - free(buf->astate); + free(((struct matrix_state*)buf->astate)); } // Adapted from cmatrix @@ -249,7 +249,7 @@ static void doom_init(struct term_buf* buf) { buf->init_width = buf->width; buf->init_height = buf->height; - buf->astate = malloc(sizeof(struct doom_state)); + buf->astate = (struct doom_state*)malloc(sizeof(struct doom_state)); if (buf->astate == NULL) { @@ -275,7 +275,7 @@ static void doom_free(struct term_buf* buf) { // cast state to doom_state pointer free(((struct doom_state*)buf->astate)->buf); - free(buf->astate); + free(((struct doom_state*)buf->astate)); } static void doom(struct term_buf* term_buf) diff --git a/src/animations.h b/src/animations.h index 51b3284..558b5f3 100644 --- a/src/animations.h +++ b/src/animations.h @@ -28,8 +28,8 @@ struct doom_state uint8_t* buf; }; -void animate_init(struct term_buf*); -void animate_free(struct term_buf*); -void animate(struct term_buf*); +void animate_init(struct term_buf* buf); +void animate_free(struct term_buf* buf); +void animate(struct term_buf* buf); #endif