summaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/llvmpipe/lp_setup.c
diff options
context:
space:
mode:
authorJosé Fonseca <[email protected]>2011-11-09 19:29:37 +0000
committerJosé Fonseca <[email protected]>2011-11-14 10:06:01 +0000
commitc88f3e0374620f18cf38d9fc3c45d14bc53f62b2 (patch)
tree05de7d375c47328da0097a62cbf239b442de85c4 /src/gallium/drivers/llvmpipe/lp_setup.c
parent9e29cdbe95810de8658dfd1cabf1a7d87264c2f7 (diff)
llvmpipe: Make more resilient to out-of-memory situations.
Most of the code was alright, but we were missing a few paths. Reviewed-by: Brian Paul <[email protected]>
Diffstat (limited to 'src/gallium/drivers/llvmpipe/lp_setup.c')
-rw-r--r--src/gallium/drivers/llvmpipe/lp_setup.c29
1 files changed, 21 insertions, 8 deletions
diff --git a/src/gallium/drivers/llvmpipe/lp_setup.c b/src/gallium/drivers/llvmpipe/lp_setup.c
index 1479ed44f0f..4f7d116d486 100644
--- a/src/gallium/drivers/llvmpipe/lp_setup.c
+++ b/src/gallium/drivers/llvmpipe/lp_setup.c
@@ -39,6 +39,7 @@
#include "util/u_inlines.h"
#include "util/u_memory.h"
#include "util/u_pack_color.h"
+#include "draw/draw_pipe.h"
#include "lp_context.h"
#include "lp_memory.h"
#include "lp_scene.h"
@@ -1010,11 +1011,13 @@ lp_setup_create( struct pipe_context *pipe,
struct draw_context *draw )
{
struct llvmpipe_screen *screen = llvmpipe_screen(pipe->screen);
- struct lp_setup_context *setup = CALLOC_STRUCT(lp_setup_context);
+ struct lp_setup_context *setup;
unsigned i;
- if (!setup)
- return NULL;
+ setup = CALLOC_STRUCT(lp_setup_context);
+ if (!setup) {
+ goto no_setup;
+ }
lp_setup_init_vbuf(setup);
@@ -1025,8 +1028,9 @@ lp_setup_create( struct pipe_context *pipe,
setup->num_threads = screen->num_threads;
setup->vbuf = draw_vbuf_stage(draw, &setup->base);
- if (!setup->vbuf)
- goto fail;
+ if (!setup->vbuf) {
+ goto no_vbuf;
+ }
draw_set_rasterize_stage(draw, setup->vbuf);
draw_set_render(draw, &setup->base);
@@ -1034,6 +1038,9 @@ lp_setup_create( struct pipe_context *pipe,
/* create some empty scenes */
for (i = 0; i < MAX_SCENES; i++) {
setup->scenes[i] = lp_scene_create( pipe );
+ if (!setup->scenes[i]) {
+ goto no_scenes;
+ }
}
setup->triangle = first_triangle;
@@ -1044,11 +1051,17 @@ lp_setup_create( struct pipe_context *pipe,
return setup;
-fail:
- if (setup->vbuf)
- ;
+no_scenes:
+ for (i = 0; i < MAX_SCENES; i++) {
+ if (setup->scenes[i]) {
+ lp_scene_destroy(setup->scenes[i]);
+ }
+ }
+ setup->vbuf->destroy(setup->vbuf);
+no_vbuf:
FREE(setup);
+no_setup:
return NULL;
}