Free PNG structs after writing

This commit is contained in:
Matthias Schiffer 2015-02-02 18:52:33 +01:00
parent 43a9df351a
commit b46c5de3ac

View file

@ -80,7 +80,7 @@ static void writePNG(const char *filename, const uint32_t data[DIM][DIM]) {
if (setjmp(png_jmpbuf(png_ptr))) { if (setjmp(png_jmpbuf(png_ptr))) {
png_destroy_write_struct(&png_ptr, &info_ptr); png_destroy_write_struct(&png_ptr, &info_ptr);
fclose(f); std::fclose(f);
throw std::runtime_error("unable to write PNG file"); throw std::runtime_error("unable to write PNG file");
} }
@ -96,6 +96,7 @@ static void writePNG(const char *filename, const uint32_t data[DIM][DIM]) {
png_set_rows(png_ptr, info_ptr, row_pointers); png_set_rows(png_ptr, info_ptr, row_pointers);
png_write_png(png_ptr, info_ptr, PNG_TRANSFORM_IDENTITY, NULL); png_write_png(png_ptr, info_ptr, PNG_TRANSFORM_IDENTITY, NULL);
png_destroy_write_struct(&png_ptr, &info_ptr);
std::fclose(f); std::fclose(f);
} }