#include #include #include "levenshtein.h" size_t** create_distance_matrix(size_t rows, size_t cols) { // Create an array of pointers to rows size_t** matrix = (size_t**) calloc(rows, sizeof(size_t*)); if ( matrix == NULL ) return NULL; // Create each row for ( size_t row = 0; row < rows; ++row ) if ( (matrix[row] = (size_t*) malloc(cols * sizeof(size_t))) == NULL ) return NULL; // Done return matrix; } void destroy_distance_matrix(size_t** matrix, size_t rows) { for ( size_t row = 0; row < rows; ++row ) free( matrix[row] ); free(matrix); }