Most of the code was alright, but we were missing a few paths.
Reviewed-by: Brian Paul <brianp@vmware.com>
unsigned i;
rast = CALLOC_STRUCT(lp_rasterizer);
- if(!rast)
- return NULL;
+ if (!rast) {
+ goto no_rast;
+ }
rast->full_scenes = lp_scene_queue_create();
+ if (!rast->full_scenes) {
+ goto no_full_scenes;
+ }
for (i = 0; i < Elements(rast->tasks); i++) {
struct lp_rasterizer_task *task = &rast->tasks[i];
memset(lp_dummy_tile, 0, sizeof lp_dummy_tile);
return rast;
+
+no_full_scenes:
+ FREE(rast);
+no_rast:
+ return NULL;
}
return NULL;
#endif
- screen = CALLOC_STRUCT(llvmpipe_screen);
-
#ifdef DEBUG
LP_DEBUG = debug_get_flags_option("LP_DEBUG", lp_debug_flags, 0 );
#endif
LP_PERF = debug_get_flags_option("LP_PERF", lp_perf_flags, 0 );
+ screen = CALLOC_STRUCT(llvmpipe_screen);
if (!screen)
return NULL;
#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"
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);
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);
/* 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;
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;
}
}
variant = generate_setup_variant(lp->gallivm, key, lp);
- insert_at_head(&lp->setup_variants_list, &variant->list_item_global);
- lp->nr_setup_variants++;
-
- llvmpipe_variant_count++;
+ if (variant) {
+ insert_at_head(&lp->setup_variants_list, &variant->list_item_global);
+ lp->nr_setup_variants++;
+ llvmpipe_variant_count++;
+ }
}
lp_setup_set_setup_variant(lp->setup,
lpr->num_slices_faces[level] = num_slices;
lpr->layout[level] = alloc_layout_array(num_slices, width, height);
+ if (!lpr->layout[level]) {
+ goto fail;
+ }
}
/* Compute size of next mipmap level */
}
return TRUE;
+
+fail:
+ for (level = 0; level <= pt->last_level; level++) {
+ if (lpr->layout[level]) {
+ FREE(lpr->layout[level]);
+ }
+ }
+
+ return FALSE;
}
lpr->img_stride[0] = 0;
lpr->layout[0] = alloc_layout_array(1, width, height);
- //lpr->layout[0][0] = LP_TEX_LAYOUT_LINEAR;
+ if (!lpr->layout[0]) {
+ return FALSE;
+ }
lpr->dt = winsys->displaytarget_create(winsys,
lpr->base.bind,
struct winsys_handle *whandle)
{
struct sw_winsys *winsys = llvmpipe_screen(screen)->winsys;
- struct llvmpipe_resource *lpr = CALLOC_STRUCT(llvmpipe_resource);
+ struct llvmpipe_resource *lpr;
unsigned width, height, width_t, height_t;
/* XXX Seems like from_handled depth textures doesn't work that well */
- if (!lpr)
- return NULL;
+ lpr = CALLOC_STRUCT(llvmpipe_resource);
+ if (!lpr) {
+ goto no_lpr;
+ }
lpr->base = *template;
pipe_reference_init(&lpr->base.reference, 1);
template,
whandle,
&lpr->row_stride[0]);
- if (!lpr->dt)
- goto fail;
+ if (!lpr->dt) {
+ goto no_dt;
+ }
lpr->layout[0] = alloc_layout_array(1, lpr->base.width0, lpr->base.height0);
+ if (!lpr->layout[0]) {
+ goto no_layout_0;
+ }
- assert(lpr->layout[0]);
assert(lpr->layout[0][0] == LP_TEX_LAYOUT_NONE);
lpr->id = id_counter++;
return &lpr->base;
- fail:
+no_layout_0:
+ winsys->displaytarget_destroy(winsys, lpr->dt);
+no_dt:
FREE(lpr);
+no_lpr:
return NULL;
}