I wrote this program that basically allocate a matrix of chars using pointer. Here's the code:
char **bitmap;
void create_bitmap() {
int i;
int columns = (int) ceil(m / 8) + 1;
bitmap = (char **) malloc(sizeof(char) * n);
for (i = 0; i < n; i++)
bitmap[i] = (char *) calloc(columns, sizeof(char));
}
void free_bitmap() {
int i;
for (i = 0; i < n; i++) {
free(bitmap[i]);
}
free(bitmap);
}
The heap block error comes out when at the last instruction of the free_bitmap() procedure. I just can't figure out what triggers the error. Thanks in advance.