how should I allocate space for this code
struct pixel **read_pixel_array(FILE *image, int pixel_array_offset, int width, int height) {
    struct pixel **pixel_array = malloc(height*sizeof(struct pixel *));
    if (pixel_array == NULL){
        perror("Unable to malloc space");
        exit(1);
    }
    for(int i = 0; i < height; i++){
        pixel_array[i] = malloc(width*sizeof(struct pixel));
        if (pixel_array[i] == NULL){
            perror("Unable to malloc space");
            exit(1);
        }
        for(int j = 0; j < width; j++){
            if (fseek(image, (pixel_array_offset + 8 * (height * i + j)), SEEK_SET) != 0){
                perror("Unable to navigate in image file");
                exit(1);
            }
            if (fread(&(pixel_array[i][j].blue), sizeof(int), 1, image) != 1){
                perror("Error when reading pixel data");
                exit(1);
            }
            if (fread(&(pixel_array[i][j].green), sizeof(int), 1, image) != 1){
                perror("Error when reading pixel data");
                exit(1);
            }
            if (fread(&(pixel_array[i][j].red), sizeof(int), 1, image) != 1){
                perror("Error when reading pixel data");
                exit(1);
            }
        }
    }
    return pixel_array;
}