[Mesa-dev] [PATCH 1/3] noop: simplify some functions

Emil Velikov emil.l.velikov at gmail.com
Mon Aug 29 17:23:58 UTC 2016


On 29 August 2016 at 16:29, Marek Olšák <maraeo at gmail.com> wrote:
> From: Marek Olšák <marek.olsak at amd.com>
>
> ---
>  src/gallium/drivers/noop/noop_state.c | 56 +++++------------------------------
>  1 file changed, 7 insertions(+), 49 deletions(-)
>
> diff --git a/src/gallium/drivers/noop/noop_state.c b/src/gallium/drivers/noop/noop_state.c
> index 0c0ad9f..01538bfe27 100644
> --- a/src/gallium/drivers/noop/noop_state.c
> +++ b/src/gallium/drivers/noop/noop_state.c
> @@ -35,63 +35,39 @@ static void noop_draw_vbo(struct pipe_context *ctx, const struct pipe_draw_info
>  }
>
>  static void noop_set_blend_color(struct pipe_context *ctx,
>                                   const struct pipe_blend_color *state)
>  {
>  }
>
>  static void *noop_create_blend_state(struct pipe_context *ctx,
>                                       const struct pipe_blend_state *state)
>  {
> -   struct pipe_blend_state *nstate = CALLOC_STRUCT(pipe_blend_state);
> -
> -   if (!nstate) {
> -      return NULL;
> -   }
> -   *nstate = *state;
> -   return nstate;
> +   return malloc(1);
You want to use [CM]ALLOC to match the FREE.

Mildly related:
Is the allocator doing to do something special for the 1 byte case or
it's going to threat it like any other "smaller than bucket size" ?

-Emil


More information about the mesa-dev mailing list