{
kds_s2000w_debug_printf(ALL, "kds_s2000w_image_converter_write_pnm");
- xel** pixels = malloc(sizeof(xel*) * height);
+ xel** pixels = pnm_allocarray(width, height);
for (uint32_t i = 0; i < height; i++) {
- pixels[i] = malloc(sizeof(xel) * width);
memset(pixels[i], 0, sizeof(xel) * width);
}
else
pnm_writepnm(pnm_stream, pixels, width, height, PGM_MAXMAXVAL, PGM_FORMAT, 0);
- for (uint32_t i = 0; i < height; i++) {
- free(pixels[i]);
- pixels[i] = NULL;
- }
- free(pixels);
+ pnm_freearray(pixels, height);
pixels = NULL;
}