From 2a878d77261457569206244e9e9d1e663e179462 Mon Sep 17 00:00:00 2001 From: Rohit Nirmal Date: Thu, 25 Sep 2014 22:47:34 -0500 Subject: [PATCH] OGL: Use unique_ptr instead of pointer when taking screenshot. --- Source/Core/VideoBackends/OGL/Render.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/Source/Core/VideoBackends/OGL/Render.cpp b/Source/Core/VideoBackends/OGL/Render.cpp index 69dbd4052f..c592d35fe1 100644 --- a/Source/Core/VideoBackends/OGL/Render.cpp +++ b/Source/Core/VideoBackends/OGL/Render.cpp @@ -1852,17 +1852,15 @@ bool Renderer::SaveScreenshot(const std::string &filename, const TargetRectangle { u32 W = back_rc.GetWidth(); u32 H = back_rc.GetHeight(); - u8 *data = new u8[W * 4 * H]; + std::unique_ptr data(new u8[W * 4 * H]); glPixelStorei(GL_PACK_ALIGNMENT, 1); - glReadPixels(back_rc.left, back_rc.bottom, W, H, GL_RGBA, GL_UNSIGNED_BYTE, data); + glReadPixels(back_rc.left, back_rc.bottom, W, H, GL_RGBA, GL_UNSIGNED_BYTE, data.get()); // Turn image upside down - FlipImageData(data, W, H, 4); - bool success = TextureToPng(data, W*4, filename, W, H, false); - delete[] data; + FlipImageData(data.get(), W, H, 4); - return success; + return TextureToPng(data.get(), W * 4, filename, W, H, false); }