From 3d91ff730ed28545eaa7f69e20370d1770d78976 Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Wed, 4 Feb 2015 14:39:49 +1000 Subject: [PATCH] renderer: cleanup context create errors and context destroy --- src/virglrenderer.c | 3 +-- src/vrend_decode.c | 10 +++++++--- src/vrend_renderer.h | 2 +- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/virglrenderer.c b/src/virglrenderer.c index 3998e2c..15ec6a7 100644 --- a/src/virglrenderer.c +++ b/src/virglrenderer.c @@ -62,8 +62,7 @@ void virgl_renderer_fill_caps(uint32_t set, uint32_t version, int virgl_renderer_context_create(uint32_t handle, uint32_t nlen, const char *name) { - vrend_renderer_context_create(handle, nlen, name); - return 0; + return vrend_renderer_context_create(handle, nlen, name); } void virgl_renderer_context_destroy(uint32_t handle) diff --git a/src/vrend_decode.c b/src/vrend_decode.c index f6ee282..1bcc5f4 100644 --- a/src/vrend_decode.c +++ b/src/vrend_decode.c @@ -985,25 +985,29 @@ void vrend_renderer_context_create_internal(uint32_t handle, uint32_t nlen, dec_ctx[handle] = dctx; } -void vrend_renderer_context_create(uint32_t handle, uint32_t nlen, const char *debug_name) +int vrend_renderer_context_create(uint32_t handle, uint32_t nlen, const char *debug_name) { if (handle > VREND_MAX_CTX) - return; + return EINVAL; /* context 0 is always available with no guarantees */ if (handle == 0) - return; + return EINVAL; vrend_renderer_context_create_internal(handle, nlen, debug_name); + return 0; } void vrend_renderer_context_destroy(uint32_t handle) { struct vrend_decode_ctx *ctx; bool ret; + if (handle > VREND_MAX_CTX) return; ctx = dec_ctx[handle]; + if (!ctx) + return; dec_ctx[handle] = NULL; ret = vrend_destroy_context(ctx->grctx); free(ctx); diff --git a/src/vrend_renderer.h b/src/vrend_renderer.h index b95091a..910a8be 100644 --- a/src/vrend_renderer.h +++ b/src/vrend_renderer.h @@ -124,7 +124,7 @@ void vrend_flush(struct vrend_context *ctx); void vrend_flush_frontbuffer(uint32_t res_handle); struct vrend_context *vrend_create_context(int id, uint32_t nlen, const char *debug_name); bool vrend_destroy_context(struct vrend_context *ctx); -void vrend_renderer_context_create(uint32_t handle, uint32_t nlen, const char *name); +int vrend_renderer_context_create(uint32_t handle, uint32_t nlen, const char *name); void vrend_renderer_context_create_internal(uint32_t handle, uint32_t nlen, const char *name); void vrend_renderer_context_destroy(uint32_t handle);