diff options
author | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2018-08-28 15:09:20 +0000 |
---|---|---|
committer | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2018-08-28 15:09:20 +0000 |
commit | 19f595718e2766cf7f7c23b1ed04b475546fce04 (patch) | |
tree | 005b70614d2a9aea8b0f68170b6c28014c674af2 /generator | |
parent | 2f7dceb3df86fb134b531171cbb7ce59b7014f89 (diff) | |
download | netpbm-mirror-19f595718e2766cf7f7c23b1ed04b475546fce04.tar.gz netpbm-mirror-19f595718e2766cf7f7c23b1ed04b475546fce04.tar.xz netpbm-mirror-19f595718e2766cf7f7c23b1ed04b475546fce04.zip |
fix memory leak
git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@3305 9d0c8265-081b-0410-96cb-a4ca84ce46f8
Diffstat (limited to 'generator')
-rw-r--r-- | generator/pamtris/triangle.c | 65 |
1 files changed, 36 insertions, 29 deletions
diff --git a/generator/pamtris/triangle.c b/generator/pamtris/triangle.c index cc9cdba2..d5d249c0 100644 --- a/generator/pamtris/triangle.c +++ b/generator/pamtris/triangle.c @@ -289,6 +289,8 @@ draw_triangle(Xy const xy_input, fract * left_attribs; fract * right_attribs; + bool degenerate_horizontal; + MALLOCARRAY_NOFAIL(top2mid_steps, num_planes); MALLOCARRAY_NOFAIL(top2bot_steps, num_planes); MALLOCARRAY_NOFAIL(mid2bot_steps, num_planes); @@ -311,7 +313,7 @@ draw_triangle(Xy const xy_input, int32_to_fract_array(attribs[top], left_attribs, num_planes); int32_to_fract_array(attribs[top], right_attribs, num_planes); - if (mid_is_to_the_left == true) { + if (mid_is_to_the_left) { upper_left_attribs_steps = top2mid_steps; lower_left_attribs_steps = mid2bot_steps; upper_right_attribs_steps = top2bot_steps; @@ -337,24 +339,20 @@ draw_triangle(Xy const xy_input, int32_to_fract_array(attribs[mid], right_attribs, num_planes); if (horizontal) { - draw_degenerate_horizontal( - xy_sorted, - left_attribs, right_attribs, - top2mid_steps, top2bot_steps, mid2bot_steps, - top2mid_delta, top2bot_delta, mid2bot_delta, - fbi - ); + degenerate_horizontal = true; + } else { + degenerate_horizontal = false; - return; + step_up(left_attribs, lower_left_attribs_steps, num_planes, + lower_left_delta); + step_up(right_attribs, lower_right_attribs_steps, num_planes, + lower_right_delta); } - - step_up(left_attribs, lower_left_attribs_steps, num_planes, - lower_left_delta); - step_up(right_attribs, lower_right_attribs_steps, num_planes, - lower_right_delta); } else { int32_t delta; + degenerate_horizontal = false; + step_up(left_attribs, upper_left_attribs_steps, num_planes, upper_left_delta); step_up(right_attribs, upper_right_attribs_steps, num_planes, @@ -390,24 +388,33 @@ draw_triangle(Xy const xy_input, multi_step_up(right_attribs, upper_right_attribs_steps, num_planes, delta, upper_right_delta); } + if (degenerate_horizontal) { + draw_degenerate_horizontal( + xy_sorted, + left_attribs, right_attribs, + top2mid_steps, top2bot_steps, mid2bot_steps, + top2mid_delta, top2bot_delta, mid2bot_delta, + fbi + ); + } else { + if (bi->start_scanline > xy._[mid][1]) { + int32_t delta = bi->start_scanline - xy._[mid][1]; - if (bi->start_scanline > xy._[mid][1]) { - int32_t delta = bi->start_scanline - xy._[mid][1]; + multi_step_up(left_attribs, lower_left_attribs_steps, + num_planes, delta, lower_left_delta); + multi_step_up(right_attribs, lower_right_attribs_steps, + num_planes, delta, lower_right_delta); + } - multi_step_up(left_attribs, lower_left_attribs_steps, - num_planes, delta, lower_left_delta); - multi_step_up(right_attribs, lower_right_attribs_steps, - num_planes, delta, lower_right_delta); + draw_partial_triangle( + left_attribs, lower_left_attribs_steps, + right_attribs, lower_right_attribs_steps, + lower_left_delta, lower_right_delta, + false, + bi, + fbi + ); } - - draw_partial_triangle( - left_attribs, lower_left_attribs_steps, - right_attribs, lower_right_attribs_steps, - lower_left_delta, lower_right_delta, - false, - bi, - fbi - ); free(right_attribs); free(left_attribs); free(mid2bot_steps); free(top2bot_steps); free(top2mid_steps); } |