OK, I acknowledge that I should check for NULL pointer when mallocing, but what about calloc? Are there any memory leaks possible?
int **initializeMatrix(int *rows, int *cols) {
int **matrix = malloc((*rows) * sizeof(int*));
checkNullPointer(matrix);
for(int i = 0; i < *rows; i++) {
matrix[i] = calloc(*cols, sizeof(int));
}
return matrix;
}
void checkNullPointer(int **ptr) {
if (ptr == NULL)
printErrorMessage(memoryErrorMessage, 101);
}