diff options
author | Konstantin Käfer <mail@kkaefer.com> | 2014-10-29 16:00:09 -0400 |
---|---|---|
committer | Konstantin Käfer <mail@kkaefer.com> | 2014-10-30 11:54:52 -0400 |
commit | 414ccaaf93fff1096086cd5c11acccc5cf5da7c3 (patch) | |
tree | 5ad7b540c3257ea6dc68f626145d7444c9ae86a0 /include/mbgl/util/image.hpp | |
parent | b3e0f75e4aa90394c5a4bda845e9843ad953cc92 (diff) | |
download | qtlocation-mapboxgl-414ccaaf93fff1096086cd5c11acccc5cf5da7c3.tar.gz |
use unique_ptr for automatic deallocation
Diffstat (limited to 'include/mbgl/util/image.hpp')
-rw-r--r-- | include/mbgl/util/image.hpp | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/include/mbgl/util/image.hpp b/include/mbgl/util/image.hpp index dc8f6a8150..0bc5af21d2 100644 --- a/include/mbgl/util/image.hpp +++ b/include/mbgl/util/image.hpp @@ -2,8 +2,7 @@ #define MBGL_UTIL_IMAGE #include <string> -#include <cstring> -#include <stdexcept> +#include <memory> namespace mbgl { namespace util { @@ -14,9 +13,8 @@ std::string compress_png(int width, int height, void *rgba, bool flip = false); class Image { public: Image(const std::string &img, bool flip = false); - ~Image(); - inline const char *getData() const { return img; } + inline const char *getData() const { return img.get(); } inline uint32_t getWidth() const { return width; } inline uint32_t getHeight() const { return height; } @@ -25,7 +23,7 @@ private: uint32_t width = 0, height = 0; // the raw image data - char *img = nullptr; + std::unique_ptr<char[]> img; }; |