Use unique_ptr instead of C array.

This commit is contained in:
Faerbit 2020-06-06 16:31:51 +02:00
parent 267df23c87
commit 3ae1c040a2

View File

@ -1,4 +1,5 @@
#include <iostream>
#include <memory>
#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<Color[]>(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";
}