aboutsummaryrefslogtreecommitdiffstats
path: root/src/egl/drivers/haiku
diff options
context:
space:
mode:
authorEmil Velikov <[email protected]>2015-06-11 13:07:08 +0100
committerEmil Velikov <[email protected]>2015-06-12 15:17:48 +0100
commitb0f33e9736116a1a6a7bd8bade51d473d7373daa (patch)
tree1a9db345cabde8297ce38d7bbf83ebd6c3369066 /src/egl/drivers/haiku
parente77a32fcaed30815d0f95e0d05432e8637ab0f3e (diff)
egl/haiku: plug some obvious memory leaks
Cc: Alexander von Gluck IV <[email protected]> Acked-by: Brian Paul <[email protected]> Signed-off-by: Emil Velikov <[email protected]>
Diffstat (limited to 'src/egl/drivers/haiku')
-rw-r--r--src/egl/drivers/haiku/egl_haiku.cpp32
1 files changed, 25 insertions, 7 deletions
diff --git a/src/egl/drivers/haiku/egl_haiku.cpp b/src/egl/drivers/haiku/egl_haiku.cpp
index 154b3af7e07..da72895ac04 100644
--- a/src/egl/drivers/haiku/egl_haiku.cpp
+++ b/src/egl/drivers/haiku/egl_haiku.cpp
@@ -192,18 +192,22 @@ haiku_add_configs_for_visuals(_EGLDisplay *dpy)
TRACE("Config configuated\n");
if (!_eglValidateConfig(&conf->base, EGL_FALSE)) {
_eglLog(_EGL_DEBUG, "Haiku: failed to validate config");
- return EGL_FALSE;
+ goto cleanup;
}
TRACE("Validated config\n");
_eglLinkConfig(&conf->base);
if (!_eglGetArraySize(dpy->Configs)) {
_eglLog(_EGL_WARNING, "Haiku: failed to create any config");
- return EGL_FALSE;
+ goto cleanup;
}
TRACE("Config successfull\n");
-
+
return EGL_TRUE;
+
+cleanup:
+ free(conf);
+ return EGL_FALSE;
}
extern "C"
@@ -213,7 +217,8 @@ init_haiku(_EGLDriver *drv, _EGLDisplay *dpy)
CALLED();
TRACE("Add configs\n");
- haiku_add_configs_for_visuals(dpy);
+ if (!haiku_add_configs_for_visuals(dpy))
+ return EGL_FALSE;
dpy->Version = 14;
@@ -246,10 +251,14 @@ haiku_create_context(_EGLDriver *drv, _EGLDisplay *disp, _EGLConfig *conf,
}
if (!_eglInitContext(&context->ctx, disp, conf, attrib_list))
- ERROR("ERROR creating context");
+ goto cleanup;
TRACE("Context created\n");
return &context->ctx;
+
+cleanup:
+ free(context);
+ return NULL;
}
@@ -257,7 +266,13 @@ extern "C"
EGLBoolean
haiku_destroy_context(_EGLDriver* drv, _EGLDisplay *disp, _EGLContext* ctx)
{
- ctx=NULL;
+ struct haiku_egl_context* context = haiku_egl_context(ctx);
+
+ if (_eglPutContext(ctx)) {
+ // XXX: teardown the context ?
+ free(context);
+ ctx = NULL
+ }
return EGL_TRUE;
}
@@ -273,7 +288,10 @@ haiku_make_current(_EGLDriver* drv, _EGLDisplay* dpy, _EGLSurface *dsurf,
struct haiku_egl_surface* surf=haiku_egl_surface(dsurf);
_EGLContext *old_ctx;
_EGLSurface *old_dsurf, *old_rsurf;
- _eglBindContext(ctx, dsurf, rsurf, &old_ctx, &old_dsurf, &old_rsurf);
+
+ if (!_eglBindContext(ctx, dsurf, rsurf, &old_ctx, &old_dsurf, &old_rsurf))
+ return EGL_FALSE;
+
//cont->ctx.DrawSurface=&surf->surf;
surf->gl->LockGL();
return EGL_TRUE;