renderengine: move away from "new"
Replace "new" by either of std::vector or std::make_unique.
Bug: 115738279
Test: boots
Change-Id: I45704b34d668198ece741894829d752035dafff6
diff --git a/services/surfaceflinger/RenderEngine/gl/GLES20RenderEngine.cpp b/services/surfaceflinger/RenderEngine/gl/GLES20RenderEngine.cpp
index b94cdca..5c4c3d5 100644
--- a/services/surfaceflinger/RenderEngine/gl/GLES20RenderEngine.cpp
+++ b/services/surfaceflinger/RenderEngine/gl/GLES20RenderEngine.cpp
@@ -116,28 +116,27 @@
EGLint wanted, EGLConfig* outConfig) {
EGLint numConfigs = -1, n = 0;
eglGetConfigs(dpy, nullptr, 0, &numConfigs);
- EGLConfig* const configs = new EGLConfig[numConfigs];
- eglChooseConfig(dpy, attrs, configs, numConfigs, &n);
+ std::vector<EGLConfig> configs(numConfigs, EGL_NO_CONFIG_KHR);
+ eglChooseConfig(dpy, attrs, configs.data(), configs.size(), &n);
+ configs.resize(n);
- if (n) {
+ if (!configs.empty()) {
if (attribute != EGL_NONE) {
- for (int i = 0; i < n; i++) {
+ for (EGLConfig config : configs) {
EGLint value = 0;
- eglGetConfigAttrib(dpy, configs[i], attribute, &value);
+ eglGetConfigAttrib(dpy, config, attribute, &value);
if (wanted == value) {
- *outConfig = configs[i];
- delete[] configs;
+ *outConfig = config;
return NO_ERROR;
}
}
} else {
// just pick the first one
*outConfig = configs[0];
- delete[] configs;
return NO_ERROR;
}
}
- delete[] configs;
+
return NAME_NOT_FOUND;
}