From 73b44c94291c4d086477167a76fd7db239936c3b Mon Sep 17 00:00:00 2001 From: Vas Crabb Date: Sun, 6 Mar 2016 18:02:37 +1100 Subject: Turn core_file into a proper class that gets cleaned up safely using unique_ptr Subverted somewhat by chd_file class --- src/tools/pngcmp.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'src/tools/pngcmp.cpp') diff --git a/src/tools/pngcmp.cpp b/src/tools/pngcmp.cpp index dda54ed7730..5103740389b 100644 --- a/src/tools/pngcmp.cpp +++ b/src/tools/pngcmp.cpp @@ -72,7 +72,7 @@ static int generate_png_diff(const std::string& imgfile1, const std::string& img bitmap_argb32 bitmap2; bitmap_argb32 finalbitmap; int width, height, maxwidth; - core_file *file = nullptr; + util::core_file::ptr file; file_error filerr; png_error pngerr; int error = 100; @@ -80,7 +80,7 @@ static int generate_png_diff(const std::string& imgfile1, const std::string& img int x, y; /* open the source image */ - filerr = core_fopen(imgfile1.c_str(), OPEN_FLAG_READ, &file); + filerr = util::core_file::open(imgfile1.c_str(), OPEN_FLAG_READ, file); if (filerr != FILERR_NONE) { printf("Could not open %s (%d)\n", imgfile1.c_str(), filerr); @@ -88,8 +88,8 @@ static int generate_png_diff(const std::string& imgfile1, const std::string& img } /* load the source image */ - pngerr = png_read_bitmap(file, bitmap1); - core_fclose(file); + pngerr = png_read_bitmap(*file, bitmap1); + file.reset(); if (pngerr != PNGERR_NONE) { printf("Could not read %s (%d)\n", imgfile1.c_str(), pngerr); @@ -97,7 +97,7 @@ static int generate_png_diff(const std::string& imgfile1, const std::string& img } /* open the source image */ - filerr = core_fopen(imgfile2.c_str(), OPEN_FLAG_READ, &file); + filerr = util::core_file::open(imgfile2.c_str(), OPEN_FLAG_READ, file); if (filerr != FILERR_NONE) { printf("Could not open %s (%d)\n", imgfile2.c_str(), filerr); @@ -105,8 +105,8 @@ static int generate_png_diff(const std::string& imgfile1, const std::string& img } /* load the source image */ - pngerr = png_read_bitmap(file, bitmap2); - core_fclose(file); + pngerr = png_read_bitmap(*file, bitmap2); + file.reset(); if (pngerr != PNGERR_NONE) { printf("Could not read %s (%d)\n", imgfile2.c_str(), pngerr); @@ -170,14 +170,14 @@ static int generate_png_diff(const std::string& imgfile1, const std::string& img } /* write the final PNG */ - filerr = core_fopen(outfilename.c_str(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE, &file); + filerr = util::core_file::open(outfilename.c_str(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE, file); if (filerr != FILERR_NONE) { printf("Could not open %s (%d)\n", outfilename.c_str(), filerr); goto error; } - pngerr = png_write_bitmap(file, nullptr, finalbitmap, 0, nullptr); - core_fclose(file); + pngerr = png_write_bitmap(*file, nullptr, finalbitmap, 0, nullptr); + file.reset(); if (pngerr != PNGERR_NONE) { printf("Could not write %s (%d)\n", outfilename.c_str(), pngerr); -- cgit v1.2.3-70-g09d2