diff options
author | Chuck Atkins <[email protected]> | 2018-01-22 12:09:28 -0500 |
---|---|---|
committer | George Kyriazis <[email protected]> | 2018-01-22 17:56:44 -0600 |
commit | a29d63ecf71546c4798c609e37810f0ec81793d8 (patch) | |
tree | 3b3a784fa47513dd284fd1f877bd8421841290bf /src/gallium/drivers/swr/swr_screen.cpp | |
parent | 56b9060381a02e9e3545c7eda3c281034a7e9b10 (diff) |
swr: refactor swr_create_screen to allow for proper cleanup on error
This makes the following changes to address cleanup issues:
- Error conditions now return NULL instead of calling exit()
- swr_creen is now freed upon error, rather than leak.
- Library handle from dlopen is now closed upon swr_screen destruction
v2: Added additional context in commit msg and remove unnecessary "PUBLIC"
v3: Fix typo in commit message.
Signed-off-by: Chuck Atkins <[email protected]>
Reviewed-by: Emil Velikov <[email protected]>
Cc: Bruce Cherniak <[email protected]>
Cc: Tim Rowley <[email protected]>
cc: [email protected]
Diffstat (limited to 'src/gallium/drivers/swr/swr_screen.cpp')
-rw-r--r-- | src/gallium/drivers/swr/swr_screen.cpp | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/src/gallium/drivers/swr/swr_screen.cpp b/src/gallium/drivers/swr/swr_screen.cpp index b67ac25ac89..839179a3043 100644 --- a/src/gallium/drivers/swr/swr_screen.cpp +++ b/src/gallium/drivers/swr/swr_screen.cpp @@ -1052,6 +1052,24 @@ swr_flush_frontbuffer(struct pipe_screen *p_screen, } +void +swr_destroy_screen_internal(struct swr_screen **screen) +{ + struct pipe_screen *p_screen = &(*screen)->base; + + swr_fence_finish(p_screen, NULL, (*screen)->flush_fence, 0); + swr_fence_reference(p_screen, &(*screen)->flush_fence, NULL); + + JitDestroyContext((*screen)->hJitMgr); + + if ((*screen)->pLibrary) + util_dl_close((*screen)->pLibrary); + + FREE(*screen); + *screen = NULL; +} + + static void swr_destroy_screen(struct pipe_screen *p_screen) { @@ -1060,15 +1078,10 @@ swr_destroy_screen(struct pipe_screen *p_screen) fprintf(stderr, "SWR destroy screen!\n"); - swr_fence_finish(p_screen, NULL, screen->flush_fence, 0); - swr_fence_reference(p_screen, &screen->flush_fence, NULL); - - JitDestroyContext(screen->hJitMgr); - if (winsys->destroy) winsys->destroy(winsys); - FREE(screen); + swr_destroy_screen_internal(&screen); } @@ -1119,6 +1132,7 @@ struct pipe_screen * swr_create_screen_internal(struct sw_winsys *winsys) { struct swr_screen *screen = CALLOC_STRUCT(swr_screen); + memset(screen, 0, sizeof(struct swr_screen)); if (!screen) return NULL; |