-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmatrix.c
36 lines (29 loc) · 782 Bytes
/
matrix.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
//
// Created by Riccardo on 18/02/2022.
//
#include "matrix.h"
int **allocate_matrix(int **matrix, int rows, int cols) {
rows = rows+1;
cols = cols+1;
matrix = (int **) calloc(rows, sizeof(int *));
for (int i = 0; i < rows; i++) {
matrix[i] = (int *) calloc(cols, sizeof(int));
}
return matrix;
}
extractlcs_matrix create_extractlcs_matrix(int **matrix, int *rows, int *columns){
*rows = *rows+1;
*columns = *columns+1;
struct Mat_struct matStruct = {matrix, columns, rows};
return matStruct;
}
void free_matrix(int **matrix, int cols) {
if (matrix != NULL) {
for (int i = 0; i < cols; ++i) {
free(matrix[i]);
matrix[i] = NULL;
}
free(matrix);
matrix = NULL;
}
}