summaryrefslogtreecommitdiffstats
path: root/minui/resources.cpp
diff options
context:
space:
mode:
authorTao Bao <tbao@google.com>2018-11-07 19:15:50 +0100
committerTao Bao <tbao@google.com>2018-11-07 23:36:45 +0100
commit9cf163e6732de5dce5b1d3b4ff7cbe19ba3a094b (patch)
tree5cc2d8d77ba8ee8c46b90fcac6e4c425545017e9 /minui/resources.cpp
parentMerge changes If24c6b7c,I381b0103 (diff)
downloadandroid_bootable_recovery-9cf163e6732de5dce5b1d3b4ff7cbe19ba3a094b.tar
android_bootable_recovery-9cf163e6732de5dce5b1d3b4ff7cbe19ba3a094b.tar.gz
android_bootable_recovery-9cf163e6732de5dce5b1d3b4ff7cbe19ba3a094b.tar.bz2
android_bootable_recovery-9cf163e6732de5dce5b1d3b4ff7cbe19ba3a094b.tar.lz
android_bootable_recovery-9cf163e6732de5dce5b1d3b4ff7cbe19ba3a094b.tar.xz
android_bootable_recovery-9cf163e6732de5dce5b1d3b4ff7cbe19ba3a094b.tar.zst
android_bootable_recovery-9cf163e6732de5dce5b1d3b4ff7cbe19ba3a094b.zip
Diffstat (limited to 'minui/resources.cpp')
-rw-r--r--minui/resources.cpp15
1 files changed, 5 insertions, 10 deletions
diff --git a/minui/resources.cpp b/minui/resources.cpp
index 9027bc668..c7af1904d 100644
--- a/minui/resources.cpp
+++ b/minui/resources.cpp
@@ -46,24 +46,19 @@ std::unique_ptr<GRSurface> GRSurface::Create(int width, int height, int row_byte
auto result = std::unique_ptr<GRSurface>(new GRSurface(width, height, row_bytes, pixel_bytes));
result->data_size_ =
(data_size + kSurfaceDataAlignment - 1) / kSurfaceDataAlignment * kSurfaceDataAlignment;
- result->data_ = static_cast<uint8_t*>(aligned_alloc(kSurfaceDataAlignment, result->data_size_));
- if (result->data_ == nullptr) return nullptr;
+ result->data_.reset(
+ static_cast<uint8_t*>(aligned_alloc(kSurfaceDataAlignment, result->data_size_)));
+ if (!result->data_) return nullptr;
return result;
}
std::unique_ptr<GRSurface> GRSurface::Clone() const {
auto result = GRSurface::Create(width, height, row_bytes, pixel_bytes, data_size_);
- memcpy(result->data_, data_, data_size_);
+ if (!result) return nullptr;
+ memcpy(result->data(), data(), data_size_);
return result;
}
-GRSurface::~GRSurface() {
- if (data_ != nullptr) {
- free(data_);
- data_ = nullptr;
- }
-}
-
PngHandler::PngHandler(const std::string& name) {
std::string res_path = g_resource_dir + "/" + name + ".png";
png_fp_.reset(fopen(res_path.c_str(), "rbe"));