aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoman Kiryanov <rkir@google.com>2019-03-27 13:22:08 -0700
committerRoman Kiryanov <rkir@google.com>2019-04-01 10:37:46 -0700
commitb2b3323f4509c62f4627284f5f36224ef2f1ac86 (patch)
tree0cd8609196e4c46cfa39b8017031570105c7f3b4
parent42b24c4513caf261360bd37cd4ba25373add59c3 (diff)
downloaddevice_generic_goldfish-opengl-b2b3323f4509c62f4627284f5f36224ef2f1ac86.tar.gz
device_generic_goldfish-opengl-b2b3323f4509c62f4627284f5f36224ef2f1ac86.tar.bz2
device_generic_goldfish-opengl-b2b3323f4509c62f4627284f5f36224ef2f1ac86.zip
Replace a manual buffer allocation with std::vector
To reduce possible memory leaks. Bug: 128324105 Test: make Change-Id: I5e1a3d2a0e0b0063878143f4362fd7ff217e337a Signed-off-by: Roman Kiryanov <rkir@google.com>
-rw-r--r--system/gralloc/gralloc.cpp9
1 files changed, 4 insertions, 5 deletions
diff --git a/system/gralloc/gralloc.cpp b/system/gralloc/gralloc.cpp
index a08873d0..851f3b02 100644
--- a/system/gralloc/gralloc.cpp
+++ b/system/gralloc/gralloc.cpp
@@ -45,6 +45,7 @@
#include <set>
#include <map>
+#include <vector>
#include <string>
#include <sstream>
@@ -384,11 +385,11 @@ static void updateHostColorBuffer(cb_handle_t* cb,
cb->frameworkFormat != HAL_PIXEL_FORMAT_YV12 &&
cb->frameworkFormat != HAL_PIXEL_FORMAT_YCbCr_420_888;
- char* convertedBuf = NULL;
+ std::vector<char> convertedBuf;
if ((doLocked && is_rgb_format) ||
(!grdma && (doLocked || !is_rgb_format))) {
- convertedBuf = new char[rgbSz];
- to_send = convertedBuf;
+ convertedBuf.resize(rgbSz);
+ to_send = convertedBuf.data();
send_buffer_size = rgbSz;
}
@@ -439,8 +440,6 @@ static void updateHostColorBuffer(cb_handle_t* cb,
left, top, width, height,
cb->glFormat, cb->glType, to_send);
}
-
- if (convertedBuf) delete [] convertedBuf;
}
#ifndef GL_RGBA16F