summaryrefslogtreecommitdiff
path: root/src/matrix.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/matrix.c')
-rw-r--r--src/matrix.c12
1 files changed, 7 insertions, 5 deletions
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 <assert.h>
+#include <string.h>
#include <stdio.h>
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");
}