On 02/17/2014 08:21 AM, Juha-Pekka Heikkila wrote:
> Signed-off-by: Juha-Pekka Heikkila <[email protected]>
> ---
> src/mesa/tnl/t_vertex.c | 41 ++++++++++++++++++++++++-----------------
> 1 file changed, 24 insertions(+), 17 deletions(-)
>
> diff --git a/src/mesa/tnl/t_vertex.c b/src/mesa/tnl/t_vertex.c
> index b3deac0..a122334 100644
> --- a/src/mesa/tnl/t_vertex.c
> +++ b/src/mesa/tnl/t_vertex.c
> @@ -81,24 +81,31 @@ void _tnl_register_fastpath( struct tnl_clipspace *vtx,
> GLboolean match_strides )
> {
> struct tnl_clipspace_fastpath *fastpath =
> CALLOC_STRUCT(tnl_clipspace_fastpath);
> - GLuint i;
> -
> - fastpath->vertex_size = vtx->vertex_size;
> - fastpath->attr_count = vtx->attr_count;
> - fastpath->match_strides = match_strides;
> - fastpath->func = vtx->emit;
> - fastpath->attr =
> - malloc(vtx->attr_count * sizeof(fastpath->attr[0]));
> -
> - for (i = 0; i < vtx->attr_count; i++) {
> - fastpath->attr[i].format = vtx->attr[i].format;
> - fastpath->attr[i].stride = vtx->attr[i].inputstride;
> - fastpath->attr[i].size = vtx->attr[i].inputsize;
> - fastpath->attr[i].offset = vtx->attr[i].vertoffset;
> - }
>
> - fastpath->next = vtx->fastpath;
> - vtx->fastpath = fastpath;
> + if (fastpath != NULL) {
I'd prefer this as
if (fastpath == NULL)
return;
It's a lot less code churn.
With that change,
Reviewed-by: Ian Romanick <[email protected]>
> + GLuint i;
> +
> + fastpath->vertex_size = vtx->vertex_size;
> + fastpath->attr_count = vtx->attr_count;
> + fastpath->match_strides = match_strides;
> + fastpath->func = vtx->emit;
> + fastpath->attr = malloc(vtx->attr_count * sizeof(fastpath->attr[0]));
> +
> + if (fastpath->attr == NULL) {
> + FREE(fastpath);
> + return;
> + }
> +
> + for (i = 0; i < vtx->attr_count; i++) {
> + fastpath->attr[i].format = vtx->attr[i].format;
> + fastpath->attr[i].stride = vtx->attr[i].inputstride;
> + fastpath->attr[i].size = vtx->attr[i].inputsize;
> + fastpath->attr[i].offset = vtx->attr[i].vertoffset;
> + }
> +
> + fastpath->next = vtx->fastpath;
> + vtx->fastpath = fastpath;
> + }
> }
>
>
_______________________________________________
mesa-dev mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/mesa-dev