Use unique_ptr instead of C array.
This commit is contained in:
parent
267df23c87
commit
3ae1c040a2
@ -1,4 +1,5 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
#include "color.h"
|
#include "color.h"
|
||||||
#include "vec3.h"
|
#include "vec3.h"
|
||||||
@ -43,7 +44,7 @@ int main() {
|
|||||||
|
|
||||||
Camera cam;
|
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) {
|
for (int j = image_height - 1; j >= 0; --j) {
|
||||||
std::cerr << "\rScanlines remaining: " << j << " " << std::flush;
|
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);
|
write_color(std::cout, image[i*image_height+j], samples_per_pixel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
delete[] image;
|
|
||||||
std::cerr << "Done.\n";
|
std::cerr << "Done.\n";
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user