Use calloc(n, size) instead of calloc(1, n * size)