changed memory allocation to calloc instead of GC_MALLOC and finsihed ms_ui_utils

This commit is contained in:
MarcUs7i 2025-01-29 20:03:52 +01:00
parent 655af3fcf4
commit 9727928404
4 changed files with 321 additions and 10 deletions

View file

@ -13,6 +13,7 @@
#include "ms_board.h"
#include "config.h"
#include <stdlib.h>
struct MsBoardData {
Count column_count;
@ -31,7 +32,7 @@ static MsBoard the_board = 0;
*/
MsBoard msb_get_board() {
if (the_board == 0) {
the_board = (MsBoard)GC_MALLOC(sizeof(struct MsBoardData));
the_board = (MsBoard)calloc(1, sizeof(struct MsBoardData));
}
return the_board;
}
@ -54,6 +55,8 @@ void msb_init_board(MsBoard board, Count column_count, Count row_count) {
board->column_count = column_count > MAX_BOARD_SIZE ? MAX_BOARD_SIZE : column_count;
board->row_count = row_count > MAX_BOARD_SIZE ? MAX_BOARD_SIZE : row_count;
msc_reset_cell_factory();
for (int row = 0; row < board->row_count; row++) {
for (int col = 0; col < board->column_count; col++) {
board->cells[col][row] = msc_produce_cell();