From a871d92723459e219ff17fd86a47c3bdd60b6230 Mon Sep 17 00:00:00 2001 From: Fabien Freling Date: Thu, 3 Jul 2014 23:53:06 +0200 Subject: [PATCH] Add image destructors. --- rotation.cpp | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/rotation.cpp b/rotation.cpp index 5d6963b..26a3b9e 100644 --- a/rotation.cpp +++ b/rotation.cpp @@ -6,11 +6,17 @@ #include #include #include +#include #include +#include using namespace std; +// +// +// Point +// template struct TPoint { @@ -22,15 +28,24 @@ struct TPoint { , y(b) {} }; + typedef TPoint Point; typedef TPoint DPoint; // absolute point, can be negative template + std::basic_ostream& operator << (std::basic_ostream& o, TPoint const& p) { o << "(" << p.x << ", " << p.y << ")"; return o; } + + +// +// +// Image +// + struct Image { unsigned int width; unsigned int height; @@ -42,6 +57,11 @@ struct Image { , buffer(NULL) {} + virtual ~Image() + { + delete [] buffer; + } + Image(unsigned int w, unsigned int h) { this->width = w; @@ -221,6 +241,16 @@ struct TiledImage : public Image { , nb_row_tile(0) {} + ~TiledImage() + { + unsigned int const nb_tiles = nb_col_tile * nb_row_tile; + for (unsigned int i = 0; i < nb_tiles; ++i) + { + delete [] tiles[i]; + } + delete [] tiles; + } + TiledImage(unsigned int w, unsigned int h) { allocate_memory(w, h);