From add2520e49da79357b7759d65f7c0863d88669b3 Mon Sep 17 00:00:00 2001 From: Elizabeth Hunt Date: Wed, 11 Oct 2023 17:00:38 -0600 Subject: bug fixes and fix compilation on gcc --- src/matrix.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'src/matrix.c') diff --git a/src/matrix.c b/src/matrix.c index a23aad4..953d50f 100644 --- a/src/matrix.c +++ b/src/matrix.c @@ -1,5 +1,6 @@ #include "lizfcm.h" #include +#include #include void put_identity_diagonal(Matrix_double *m) { @@ -69,14 +70,15 @@ void free_matrix(Matrix_double *m) { } void format_matrix_into(Matrix_double *m, char *s) { - sprintf(s, ""); if (m->rows == 0) - sprintf(s, "empty"); + strcpy(s, "empty"); for (size_t y = 0; y < m->rows; ++y) { - char *row_s = malloc(sizeof(char) * 256); + char row_s[256]; + strcpy(row_s, ""); + format_vector_into(m->data[y], row_s); - sprintf(s, "%s %s \n", s, row_s); - free(row_s); + strcat(s, row_s); } + strcat(s, "\n"); } -- cgit v1.2.3-70-g09d2