[Mesa-dev] [PATCH] intel: callocing a 32 byte temp is silly, so don't
Anuj Phogat
anuj.phogat at gmail.com
Wed Jan 23 22:26:33 PST 2013
On Thu, Jan 24, 2013 at 10:06 AM, Ian Romanick <idr at freedesktop.org> wrote:
> From: Ian Romanick <ian.d.romanick at intel.com>
>
> I believe that the size used to vary, so the dynamic allocation is
> necessary.
>
> Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
> ---
> src/mesa/drivers/dri/intel/intel_context.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/src/mesa/drivers/dri/intel/intel_context.c b/src/mesa/drivers/dri/intel/intel_context.c
> index ab97d66..3aa35e6 100644
> --- a/src/mesa/drivers/dri/intel/intel_context.c
> +++ b/src/mesa/drivers/dri/intel/intel_context.c
> @@ -984,8 +984,8 @@ intel_query_dri2_buffers(struct intel_context *intel,
> __DRIscreen *screen = intel->intelScreen->driScrnPriv;
> struct gl_framebuffer *fb = drawable->driverPrivate;
> int i = 0;
> - const int max_attachments = 4;
> - unsigned *attachments = calloc(2 * max_attachments, sizeof(unsigned));
> + unsigned attachments[8];
> + const int max_attachments = ARRAY_SIZE(attachments) / 2;
>
> struct intel_renderbuffer *front_rb;
> struct intel_renderbuffer *back_rb;
> @@ -993,6 +993,7 @@ intel_query_dri2_buffers(struct intel_context *intel,
> front_rb = intel_get_renderbuffer(fb, BUFFER_FRONT_LEFT);
> back_rb = intel_get_renderbuffer(fb, BUFFER_BACK_LEFT);
>
> + memset(attachments, 0, sizeof(attachments));
> if ((intel->is_front_buffer_rendering ||
> intel->is_front_buffer_reading ||
> !back_rb) && front_rb) {
> @@ -1013,7 +1014,6 @@ intel_query_dri2_buffers(struct intel_context *intel,
> attachments, i / 2,
> buffer_count,
> drawable->loaderPrivate);
> - free(attachments);
> }
>
> /**
> --
> 1.7.11.7
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Reviewed-by: Anuj Phogat <anuj.phogat at gmail.com>
More information about the mesa-dev
mailing list