Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(115)

Unified Diff: compositor/mock_compositor.cc

Issue 6691037: wm: Fix an uncommon memory leak in the compositor code. (Closed) Base URL: ssh://gitrw.chromium.org:9222/window_manager.git@master
Patch Set: update another arg to be a const ref Created 9 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « compositor/mock_compositor.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: compositor/mock_compositor.cc
diff --git a/compositor/mock_compositor.cc b/compositor/mock_compositor.cc
index df6a0f1b24d98a042550a2110cd4713746337506..158754860d8d497dd6b03e13870434b44ed8ccdc 100644
--- a/compositor/mock_compositor.cc
+++ b/compositor/mock_compositor.cc
@@ -146,7 +146,6 @@ void MockCompositor::ImageActor::SetImageData(
MockCompositor::TexturePixmapActor::TexturePixmapActor(XConnection* xconn)
: xconn_(xconn),
- alpha_mask_bytes_(NULL),
pixmap_(0),
num_texture_updates_(0),
damaged_region_() {
@@ -154,7 +153,6 @@ MockCompositor::TexturePixmapActor::TexturePixmapActor(XConnection* xconn)
}
MockCompositor::TexturePixmapActor::~TexturePixmapActor() {
- ClearAlphaMask();
}
void MockCompositor::TexturePixmapActor::SetPixmap(XWindow pixmap) {
@@ -171,13 +169,12 @@ void MockCompositor::TexturePixmapActor::SetAlphaMask(
const uint8_t* bytes, int width, int height) {
ClearAlphaMask();
size_t size = width * height;
- alpha_mask_bytes_ = new unsigned char[size];
- memcpy(alpha_mask_bytes_, bytes, size);
+ alpha_mask_bytes_.reset(new uint8_t[size]);
+ memcpy(alpha_mask_bytes_.get(), bytes, size);
}
void MockCompositor::TexturePixmapActor::ClearAlphaMask() {
- delete[] alpha_mask_bytes_;
- alpha_mask_bytes_ = NULL;
+ alpha_mask_bytes_.reset();
}
MockCompositor::ImageActor* MockCompositor::CreateImageFromFile(
« no previous file with comments | « compositor/mock_compositor.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698