mesa/swrast: Move memory allocation outside the blit loop
authorIan Romanick <ian.d.romanick@intel.com>
Mon, 15 Apr 2013 19:25:18 +0000 (12:25 -0700)
committerIan Romanick <ian.d.romanick@intel.com>
Tue, 16 Apr 2013 17:18:14 +0000 (10:18 -0700)
commit025f03f3b70989d27a20fea42763e3ccac946aa4
treefca8bdc702baf717f5470ea3ceef2d43023d5742
parenta27c6e1aea1d048e0c701ca59c3c5bcf12b69d7b
mesa/swrast: Move memory allocation outside the blit loop

Assume the maximum pixel size (16 bytes per pixel).  In addition to
moving redundant malloc and free calls outside the loop, this fixes a
potential resource leak when a surface is mapped and the malloc fails.
This also makes blit_nearest look a bit more like blit_linear.

v2: Use MAX_PIXEL_BYTES instead of 16.  Suggested by Ken.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
src/mesa/swrast/s_blit.c