Mesa (gallium-0.2): stw: clean up error paths

Keith Whitwell keithw at kemper.freedesktop.org
Mon Feb 2 12:21:36 UTC 2009


Module: Mesa
Branch: gallium-0.2
Commit: 866587942c7053cdcb7443ed00ce6d902c010631
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=866587942c7053cdcb7443ed00ce6d902c010631

Author: Keith Whitwell <keith at tungstengraphics.com>
Date:   Wed Jan 28 20:19:17 2009 +0000

stw: clean up error paths

---

 .../state_trackers/wgl/shared/stw_context.c        |   42 ++++++++++---------
 1 files changed, 22 insertions(+), 20 deletions(-)

diff --git a/src/gallium/state_trackers/wgl/shared/stw_context.c b/src/gallium/state_trackers/wgl/shared/stw_context.c
index 6a26c16..62e26ab 100644
--- a/src/gallium/state_trackers/wgl/shared/stw_context.c
+++ b/src/gallium/state_trackers/wgl/shared/stw_context.c
@@ -64,10 +64,10 @@ stw_create_context(
    int iLayerPlane )
 {
    uint pfi;
-   const struct pixelformat_info *pf;
-   struct wgl_context *ctx;
-   GLvisual *visual;
-   struct pipe_context *pipe;
+   const struct pixelformat_info *pf = NULL;
+   struct wgl_context *ctx = NULL;
+   GLvisual *visual = NULL;
+   struct pipe_context *pipe = NULL;
 
    if (iLayerPlane != 0)
       return NULL;
@@ -103,34 +103,36 @@ stw_create_context(
       0,
       0,
       (pf->flags & PF_FLAG_MULTISAMPLED) ? stw_query_samples() : 0 );
-   if (visual == NULL) {
-      FREE( ctx );
-      return NULL;
-   }
+   if (visual == NULL) 
+      goto fail;
 
    pipe = stw_dev->stw_winsys->create_context( stw_dev->screen );
-   if (!pipe) {
-      _mesa_destroy_visual( visual );
-      FREE( ctx );
-      return NULL;
-   }
-   
+   if (pipe == NULL) 
+      goto fail;
+
    assert(!pipe->priv);
    pipe->priv = hdc;
 
    ctx->st = st_create_context( pipe, visual, NULL );
-   if (ctx->st == NULL) {
-      pipe->destroy( pipe );
-      _mesa_destroy_visual( visual );
-      FREE( ctx );
-      return NULL;
-   }
+   if (ctx->st == NULL) 
+      goto fail;
+
    ctx->st->ctx->DriverCtx = ctx;
 
    ctx->next = ctx_head;
    ctx_head = ctx;
 
    return (HGLRC) ctx;
+
+fail:
+   if (visual)
+      _mesa_destroy_visual( visual );
+   
+   if (pipe)
+      pipe->destroy( pipe );
+      
+   FREE( ctx );
+   return NULL;
 }
 
 




More information about the mesa-commit mailing list