From 3ae1c040a240b950b62b6eb97fc74d69f0530e9f Mon Sep 17 00:00:00 2001 From: Faerbit Date: Sat, 6 Jun 2020 16:31:51 +0200 Subject: [PATCH] Use unique_ptr instead of C array. --- wtracer.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wtracer.cpp b/wtracer.cpp index d197041..28ba327 100644 --- a/wtracer.cpp +++ b/wtracer.cpp @@ -1,4 +1,5 @@ #include +#include #include "color.h" #include "vec3.h" @@ -43,7 +44,7 @@ int main() { Camera cam; - Color* image = new Color[image_height*image_width]; + auto image = std::make_unique(image_height*image_width); for (int j = image_height - 1; j >= 0; --j) { std::cerr << "\rScanlines remaining: " << j << " " << std::flush; @@ -65,6 +66,5 @@ int main() { write_color(std::cout, image[i*image_height+j], samples_per_pixel); } } - delete[] image; std::cerr << "Done.\n"; }