[Mesa-dev] [PATCH 01/12] mesa: Use realloc() instead of _mesa_realloc() and remove the latter.

Emil Velikov emil.l.velikov at gmail.com
Tue Sep 23 12:13:09 PDT 2014


Patches 01-08 and 10 are (v2 for patch 03 and 03 :P)
Reviewed-by: Emil Velikov <emil.l.velikov at gmail.com>

Would prefer it we can hold off 11 and 12 until we get any yay/nay on
the topic.

Thanks
Emil

P.S. It seems that egl and gbm did not get the utils treatment,
including some parts of mapi. We can do that as a follow up :)



On 22/09/14 19:50, Matt Turner wrote:
> ---
>  src/gallium/state_trackers/glx/xlib/glx_api.c |  3 +--
>  src/mesa/drivers/x11/fakeglx.c                |  3 +--
>  src/mesa/main/imports.c                       | 14 --------------
>  src/mesa/main/imports.h                       |  3 ---
>  src/mesa/main/shaderapi.c                     |  5 ++---
>  src/mesa/program/prog_instruction.c           |  5 ++---
>  src/mesa/program/prog_parameter.c             |  5 ++---
>  7 files changed, 8 insertions(+), 30 deletions(-)
> 
> diff --git a/src/gallium/state_trackers/glx/xlib/glx_api.c b/src/gallium/state_trackers/glx/xlib/glx_api.c
> index d97cbd7..84b605a 100644
> --- a/src/gallium/state_trackers/glx/xlib/glx_api.c
> +++ b/src/gallium/state_trackers/glx/xlib/glx_api.c
> @@ -248,8 +248,7 @@ save_glx_visual( Display *dpy, XVisualInfo *vinfo,
>         */
>        xmvis->vishandle = vinfo;
>        /* Allocate more space for additional visual */
> -      VisualTable = (XMesaVisual *) _mesa_realloc( VisualTable, 
> -                                   sizeof(XMesaVisual) * NumVisuals, 
> +      VisualTable = (XMesaVisual *) realloc( VisualTable,
>                                     sizeof(XMesaVisual) * (NumVisuals + 1));
>        /* add xmvis to the list */
>        VisualTable[NumVisuals] = xmvis;
> diff --git a/src/mesa/drivers/x11/fakeglx.c b/src/mesa/drivers/x11/fakeglx.c
> index eba13ac..a47ad74 100644
> --- a/src/mesa/drivers/x11/fakeglx.c
> +++ b/src/mesa/drivers/x11/fakeglx.c
> @@ -326,8 +326,7 @@ save_glx_visual( Display *dpy, XVisualInfo *vinfo,
>         */
>        xmvis->vishandle = vinfo;
>        /* Allocate more space for additional visual */
> -      VisualTable = (XMesaVisual *) _mesa_realloc( VisualTable, 
> -                                   sizeof(XMesaVisual) * NumVisuals, 
> +      VisualTable = (XMesaVisual *) realloc( VisualTable,
>                                     sizeof(XMesaVisual) * (NumVisuals + 1));
>        /* add xmvis to the list */
>        VisualTable[NumVisuals] = xmvis;
> diff --git a/src/mesa/main/imports.c b/src/mesa/main/imports.c
> index 4afe156..c5a7d63 100644
> --- a/src/mesa/main/imports.c
> +++ b/src/mesa/main/imports.c
> @@ -209,20 +209,6 @@ _mesa_align_realloc(void *oldBuffer, size_t oldSize, size_t newSize,
>  #endif
>  }
>  
> -
> -
> -/** Reallocate memory */
> -void *
> -_mesa_realloc(void *oldBuffer, size_t oldSize, size_t newSize)
> -{
> -   const size_t copySize = (oldSize < newSize) ? oldSize : newSize;
> -   void *newBuffer = malloc(newSize);
> -   if (newBuffer && oldBuffer && copySize > 0)
> -      memcpy(newBuffer, oldBuffer, copySize);
> -   free(oldBuffer);
> -   return newBuffer;
> -}
> -
>  /*@}*/
>  
>  
> diff --git a/src/mesa/main/imports.h b/src/mesa/main/imports.h
> index 59fd19c..8dbcf83 100644
> --- a/src/mesa/main/imports.h
> +++ b/src/mesa/main/imports.h
> @@ -473,9 +473,6 @@ _mesa_exec_malloc( GLuint size );
>  extern void 
>  _mesa_exec_free( void *addr );
>  
> -extern void *
> -_mesa_realloc( void *oldBuffer, size_t oldSize, size_t newSize );
> -
>  
>  #ifndef FFS_DEFINED
>  #define FFS_DEFINED 1
> diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c
> index 620cab3..dc8b255 100644
> --- a/src/mesa/main/shaderapi.c
> +++ b/src/mesa/main/shaderapi.c
> @@ -272,9 +272,8 @@ attach_shader(struct gl_context *ctx, GLuint program, GLuint shader)
>  
>     /* grow list */
>     shProg->Shaders = (struct gl_shader **)
> -      _mesa_realloc(shProg->Shaders,
> -                    n * sizeof(struct gl_shader *),
> -                    (n + 1) * sizeof(struct gl_shader *));
> +      realloc(shProg->Shaders,
> +              (n + 1) * sizeof(struct gl_shader *));
>     if (!shProg->Shaders) {
>        _mesa_error(ctx, GL_OUT_OF_MEMORY, "glAttachShader");
>        return;
> diff --git a/src/mesa/program/prog_instruction.c b/src/mesa/program/prog_instruction.c
> index dc0a510..e2eadc3 100644
> --- a/src/mesa/program/prog_instruction.c
> +++ b/src/mesa/program/prog_instruction.c
> @@ -90,9 +90,8 @@ _mesa_realloc_instructions(struct prog_instruction *oldInst,
>     struct prog_instruction *newInst;
>  
>     newInst = (struct prog_instruction *)
> -      _mesa_realloc(oldInst,
> -                    numOldInst * sizeof(struct prog_instruction),
> -                    numNewInst * sizeof(struct prog_instruction));
> +      realloc(oldInst,
> +              numNewInst * sizeof(struct prog_instruction));
>  
>     return newInst;
>  }
> diff --git a/src/mesa/program/prog_parameter.c b/src/mesa/program/prog_parameter.c
> index f43deba..896c605 100644
> --- a/src/mesa/program/prog_parameter.c
> +++ b/src/mesa/program/prog_parameter.c
> @@ -121,9 +121,8 @@ _mesa_add_parameter(struct gl_program_parameter_list *paramList,
>  
>        /* realloc arrays */
>        paramList->Parameters = (struct gl_program_parameter *)
> -	 _mesa_realloc(paramList->Parameters,
> -		       oldNum * sizeof(struct gl_program_parameter),
> -		       paramList->Size * sizeof(struct gl_program_parameter));
> +         realloc(paramList->Parameters,
> +                 paramList->Size * sizeof(struct gl_program_parameter));
>  
>        paramList->ParameterValues = (gl_constant_value (*)[4])
>           _mesa_align_realloc(paramList->ParameterValues,         /* old buf */
> 



More information about the mesa-dev mailing list