[Mesa-dev] [PATCH 26/28] replace imports memory functions with utils memory functions

Dylan Baker dylan at pnwbakers.com
Fri Nov 9 18:40:19 UTC 2018


---
 src/compiler/SConscript.glsl                  |   2 -
 src/mesa/Android.libmesa_glsl_utils.mk        |   2 -
 .../drivers/dri/i915/intel_buffer_objects.c   |  19 ++-
 src/mesa/drivers/dri/i965/intel_mipmap_tree.c |   9 +-
 src/mesa/main/bufferobj.c                     |   7 +-
 src/mesa/main/imports.c                       | 148 ------------------
 src/mesa/main/imports.h                       |  18 ---
 src/mesa/math/m_debug_norm.c                  |   5 +-
 src/mesa/math/m_debug_xform.c                 |   5 +-
 src/mesa/math/m_matrix.c                      |  11 +-
 src/mesa/math/m_vector.c                      |   7 +-
 src/mesa/program/prog_parameter.c             |  15 +-
 src/mesa/swrast/s_texture.c                   |   4 +-
 src/mesa/tnl/t_vb_program.c                   |   6 +-
 src/mesa/tnl/t_vb_vertex.c                    |   6 +-
 src/mesa/tnl/t_vertex.c                       |   4 +-
 src/mesa/vbo/vbo_exec_api.c                   |   7 +-
 17 files changed, 52 insertions(+), 223 deletions(-)

diff --git a/src/compiler/SConscript.glsl b/src/compiler/SConscript.glsl
index a25374fce3d..8154aa6d9e8 100644
--- a/src/compiler/SConscript.glsl
+++ b/src/compiler/SConscript.glsl
@@ -69,7 +69,6 @@ if env['msvc']:
 
 # Copy these files to avoid generation object files into src/mesa/program
 env.Prepend(CPPPATH = ['#src/mesa/main'])
-env.Command('glsl/imports.c', '#src/mesa/main/imports.c', Copy('$TARGET', '$SOURCE'))
 env.Command('glsl/extensions_table.c', '#src/mesa/main/extensions_table.c', Copy('$TARGET', '$SOURCE'))
 # Copy these files to avoid generation object files into src/mesa/program
 env.Prepend(CPPPATH = ['#src/mesa/program'])
@@ -80,7 +79,6 @@ compiler_objs = env.StaticObject(source_lists['GLSL_COMPILER_CXX_FILES'])
 
 mesa_objs = env.StaticObject([
     'glsl/extensions_table.c',
-    'glsl/imports.c',
     'glsl/symbol_table.c',
     'glsl/dummy_errors.c',
 ])
diff --git a/src/mesa/Android.libmesa_glsl_utils.mk b/src/mesa/Android.libmesa_glsl_utils.mk
index 0d83cd5a9bf..66b6ef13a61 100644
--- a/src/mesa/Android.libmesa_glsl_utils.mk
+++ b/src/mesa/Android.libmesa_glsl_utils.mk
@@ -43,7 +43,6 @@ LOCAL_C_INCLUDES := \
 
 LOCAL_SRC_FILES := \
 	main/extensions_table.c \
-	main/imports.c \
 	program/symbol_table.c \
 	program/dummy_errors.c
 
@@ -68,7 +67,6 @@ LOCAL_C_INCLUDES := \
 
 LOCAL_SRC_FILES := \
 	main/extensions_table.c \
-	main/imports.c \
 	program/symbol_table.c \
 	program/dummy_errors.c
 
diff --git a/src/mesa/drivers/dri/i915/intel_buffer_objects.c b/src/mesa/drivers/dri/i915/intel_buffer_objects.c
index f4e9fcfefee..a1b47134865 100644
--- a/src/mesa/drivers/dri/i915/intel_buffer_objects.c
+++ b/src/mesa/drivers/dri/i915/intel_buffer_objects.c
@@ -26,7 +26,6 @@
  **************************************************************************/
 
 
-#include "main/imports.h"
 #include "main/mtypes.h"
 #include "main/macros.h"
 #include "main/bufferobj.h"
@@ -97,7 +96,7 @@ intel_bufferobj_free(struct gl_context * ctx, struct gl_buffer_object *obj)
     */
    _mesa_buffer_unmap_all_mappings(ctx, obj);
 
-   _mesa_align_free(intel_obj->sys_buffer);
+   align_free(intel_obj->sys_buffer);
 
    drm_intel_bo_unreference(intel_obj->buffer);
    _mesa_delete_buffer_object(ctx, obj);
@@ -134,7 +133,7 @@ intel_bufferobj_data(struct gl_context * ctx,
    if (intel_obj->buffer != NULL)
       release_buffer(intel_obj);
 
-   _mesa_align_free(intel_obj->sys_buffer);
+   align_free(intel_obj->sys_buffer);
    intel_obj->sys_buffer = NULL;
 
    if (size != 0) {
@@ -143,7 +142,7 @@ intel_bufferobj_data(struct gl_context * ctx,
        */
       if (target == GL_ARRAY_BUFFER || target == GL_ELEMENT_ARRAY_BUFFER) {
 	 intel_obj->sys_buffer =
-            _mesa_align_malloc(size, ctx->Const.MinMapBufferAlignment);
+            align_malloc(size, ctx->Const.MinMapBufferAlignment);
 	 if (intel_obj->sys_buffer != NULL) {
 	    if (data != NULL)
 	       memcpy(intel_obj->sys_buffer, data, size);
@@ -194,7 +193,7 @@ intel_bufferobj_subdata(struct gl_context * ctx,
 	 return;
       }
 
-      _mesa_align_free(intel_obj->sys_buffer);
+      align_free(intel_obj->sys_buffer);
       intel_obj->sys_buffer = NULL;
    }
 
@@ -302,7 +301,7 @@ intel_bufferobj_map_range(struct gl_context * ctx,
 	 return obj->Mappings[index].Pointer;
       }
 
-      _mesa_align_free(intel_obj->sys_buffer);
+      align_free(intel_obj->sys_buffer);
       intel_obj->sys_buffer = NULL;
    }
 
@@ -351,7 +350,7 @@ intel_bufferobj_map_range(struct gl_context * ctx,
 
       if (access & GL_MAP_FLUSH_EXPLICIT_BIT) {
          intel_obj->range_map_buffer[index] =
-            _mesa_align_malloc(length + extra, alignment);
+            align_malloc(length + extra, alignment);
          obj->Mappings[index].Pointer =
             intel_obj->range_map_buffer[index] + extra;
       } else {
@@ -446,7 +445,7 @@ intel_bufferobj_unmap(struct gl_context * ctx, struct gl_buffer_object *obj,
        * usage inside of a batchbuffer.
        */
       intel_batchbuffer_emit_mi_flush(intel);
-      _mesa_align_free(intel_obj->range_map_buffer[index]);
+      align_free(intel_obj->range_map_buffer[index]);
       intel_obj->range_map_buffer[index] = NULL;
    } else if (intel_obj->range_map_bo[index] != NULL) {
       const unsigned extra = obj->Mappings[index].Pointer -
@@ -491,7 +490,7 @@ intel_bufferobj_buffer(struct intel_context *intel,
 			   0, intel_obj->Base.Size,
 			   intel_obj->sys_buffer);
 
-      _mesa_align_free(intel_obj->sys_buffer);
+      align_free(intel_obj->sys_buffer);
       intel_obj->sys_buffer = NULL;
       intel_obj->offset = 0;
    }
@@ -678,7 +677,7 @@ intel_buffer_object_purgeable(struct gl_context * ctx,
       return intel_buffer_purgeable(intel_obj->buffer);
 
    if (option == GL_RELEASED_APPLE) {
-      _mesa_align_free(intel_obj->sys_buffer);
+      align_free(intel_obj->sys_buffer);
       intel_obj->sys_buffer = NULL;
 
       return GL_RELEASED_APPLE;
diff --git a/src/mesa/drivers/dri/i965/intel_mipmap_tree.c b/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
index 8e50aabb3b4..fbf17952e3d 100644
--- a/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
+++ b/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
@@ -49,6 +49,7 @@
 #include "main/streaming-load-memcpy.h"
 
 #include "util/format_srgb.h"
+#include "util/u_memory.h"
 
 #include "x86/common_x86_asm.h"
 
@@ -3132,7 +3133,7 @@ intel_miptree_unmap_tiled_memcpy(struct brw_context *brw,
 
       intel_miptree_unmap_raw(mt);
    }
-   _mesa_align_free(map->buffer);
+   align_free(map->buffer);
    map->buffer = map->ptr = NULL;
 }
 
@@ -3154,7 +3155,7 @@ intel_miptree_map_tiled_memcpy(struct brw_context *brw,
     * aligned). Here we over-allocate the linear buffer by enough
     * bytes to get the proper alignment.
     */
-   map->buffer = _mesa_align_malloc(map->stride * (y2 - y1) + (x1 & 0xf), 16);
+   map->buffer = align_malloc(map->stride * (y2 - y1) + (x1 & 0xf), 16);
    map->ptr = (char *)map->buffer + (x1 & 0xf);
    assert(map->buffer);
 
@@ -3252,7 +3253,7 @@ intel_miptree_unmap_movntdqa(struct brw_context *brw,
                              unsigned int level,
                              unsigned int slice)
 {
-   _mesa_align_free(map->buffer);
+   align_free(map->buffer);
    map->buffer = NULL;
    map->ptr = NULL;
 }
@@ -3302,7 +3303,7 @@ intel_miptree_map_movntdqa(struct brw_context *brw,
 
    map->stride = ALIGN(misalignment + width_bytes, 16);
 
-   map->buffer = _mesa_align_malloc(map->stride * map->h, 16);
+   map->buffer = align_malloc(map->stride * map->h, 16);
    /* Offset the destination so it has the same misalignment as src. */
    map->ptr = map->buffer + misalignment;
 
diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c
index dda9efc3c6e..02ea4008dbd 100644
--- a/src/mesa/main/bufferobj.c
+++ b/src/mesa/main/bufferobj.c
@@ -36,7 +36,6 @@
 #include "glheader.h"
 #include "enums.h"
 #include "hash.h"
-#include "imports.h"
 #include "context.h"
 #include "bufferobj.h"
 #include "externalobjects.h"
@@ -466,7 +465,7 @@ _mesa_delete_buffer_object(struct gl_context *ctx,
    (void) ctx;
 
    vbo_delete_minmax_cache(bufObj);
-   _mesa_align_free(bufObj->Data);
+   align_free(bufObj->Data);
 
    /* assign strange values here to help w/ debugging */
    bufObj->RefCount = -1000;
@@ -606,9 +605,9 @@ buffer_data_fallback(struct gl_context *ctx, GLenum target, GLsizeiptrARB size,
 
    (void) target;
 
-   _mesa_align_free( bufObj->Data );
+   align_free( bufObj->Data );
 
-   new_data = _mesa_align_malloc( size, ctx->Const.MinMapBufferAlignment );
+   new_data = align_malloc( size, ctx->Const.MinMapBufferAlignment );
    if (new_data) {
       bufObj->Data = (GLubyte *) new_data;
       bufObj->Size = size;
diff --git a/src/mesa/main/imports.c b/src/mesa/main/imports.c
index 7a770d42b73..070d7ada0b8 100644
--- a/src/mesa/main/imports.c
+++ b/src/mesa/main/imports.c
@@ -63,151 +63,3 @@
 #elif defined(__IBMC__) || defined(__IBMCPP__)
 extern int vsnprintf(char *str, size_t count, const char *fmt, va_list arg);
 #endif
-
-/**********************************************************************/
-/** \name Memory */
-/*@{*/
-
-/**
- * Allocate aligned memory.
- *
- * \param bytes number of bytes to allocate.
- * \param alignment alignment (must be greater than zero).
- * 
- * Allocates extra memory to accommodate rounding up the address for
- * alignment and to record the real malloc address.
- *
- * \sa _mesa_align_free().
- */
-void *
-_mesa_align_malloc(size_t bytes, unsigned long alignment)
-{
-#if defined(HAVE_POSIX_MEMALIGN)
-   void *mem;
-   int err = posix_memalign(& mem, alignment, bytes);
-   if (err)
-      return NULL;
-   return mem;
-#elif defined(_WIN32)
-   return _aligned_malloc(bytes, alignment);
-#else
-   uintptr_t ptr, buf;
-
-   assert( alignment > 0 );
-
-   ptr = (uintptr_t)malloc(bytes + alignment + sizeof(void *));
-   if (!ptr)
-      return NULL;
-
-   buf = (ptr + alignment + sizeof(void *)) & ~(uintptr_t)(alignment - 1);
-   *(uintptr_t *)(buf - sizeof(void *)) = ptr;
-
-#ifdef DEBUG
-   /* mark the non-aligned area */
-   while ( ptr < buf - sizeof(void *) ) {
-      *(unsigned long *)ptr = 0xcdcdcdcd;
-      ptr += sizeof(unsigned long);
-   }
-#endif
-
-   return (void *) buf;
-#endif /* defined(HAVE_POSIX_MEMALIGN) */
-}
-
-/**
- * Same as _mesa_align_malloc(), but using calloc(1, ) instead of
- * malloc()
- */
-void *
-_mesa_align_calloc(size_t bytes, unsigned long alignment)
-{
-#if defined(HAVE_POSIX_MEMALIGN)
-   void *mem;
-   
-   mem = _mesa_align_malloc(bytes, alignment);
-   if (mem != NULL) {
-      (void) memset(mem, 0, bytes);
-   }
-
-   return mem;
-#elif defined(_WIN32)
-   void *mem;
-
-   mem = _aligned_malloc(bytes, alignment);
-   if (mem != NULL) {
-      (void) memset(mem, 0, bytes);
-   }
-
-   return mem;
-#else
-   uintptr_t ptr, buf;
-
-   assert( alignment > 0 );
-
-   ptr = (uintptr_t)calloc(1, bytes + alignment + sizeof(void *));
-   if (!ptr)
-      return NULL;
-
-   buf = (ptr + alignment + sizeof(void *)) & ~(uintptr_t)(alignment - 1);
-   *(uintptr_t *)(buf - sizeof(void *)) = ptr;
-
-#ifdef DEBUG
-   /* mark the non-aligned area */
-   while ( ptr < buf - sizeof(void *) ) {
-      *(unsigned long *)ptr = 0xcdcdcdcd;
-      ptr += sizeof(unsigned long);
-   }
-#endif
-
-   return (void *)buf;
-#endif /* defined(HAVE_POSIX_MEMALIGN) */
-}
-
-/**
- * Free memory which was allocated with either _mesa_align_malloc()
- * or _mesa_align_calloc().
- * \param ptr pointer to the memory to be freed.
- * The actual address to free is stored in the word immediately before the
- * address the client sees.
- * Note that it is legal to pass NULL pointer to this function and will be
- * handled accordingly.
- */
-void
-_mesa_align_free(void *ptr)
-{
-#if defined(HAVE_POSIX_MEMALIGN)
-   free(ptr);
-#elif defined(_WIN32)
-   _aligned_free(ptr);
-#else
-   if (ptr) {
-      void **cubbyHole = (void **) ((char *) ptr - sizeof(void *));
-      void *realAddr = *cubbyHole;
-      free(realAddr);
-   }
-#endif /* defined(HAVE_POSIX_MEMALIGN) */
-}
-
-/**
- * Reallocate memory, with alignment.
- */
-void *
-_mesa_align_realloc(void *oldBuffer, size_t oldSize, size_t newSize,
-                    unsigned long alignment)
-{
-#if defined(_WIN32)
-   (void) oldSize;
-   return _aligned_realloc(oldBuffer, newSize, alignment);
-#else
-   const size_t copySize = (oldSize < newSize) ? oldSize : newSize;
-   void *newBuf = _mesa_align_malloc(newSize, alignment);
-   if (newBuf && oldBuffer && copySize > 0) {
-      memcpy(newBuf, oldBuffer, copySize);
-   }
-
-   _mesa_align_free(oldBuffer);
-   return newBuf;
-#endif
-}
-
-/*@}*/
diff --git a/src/mesa/main/imports.h b/src/mesa/main/imports.h
index 2454bee7015..f51e9d9b7a6 100644
--- a/src/mesa/main/imports.h
+++ b/src/mesa/main/imports.h
@@ -71,24 +71,6 @@ typedef union { GLfloat f; GLint i; GLuint u; } fi_type;
 /*@}*/
 
 
-/**********************************************************************
- * Functions
- */
-
-extern void *
-_mesa_align_malloc( size_t bytes, unsigned long alignment );
-
-extern void *
-_mesa_align_calloc( size_t bytes, unsigned long alignment );
-
-extern void
-_mesa_align_free( void *ptr );
-
-extern void *
-_mesa_align_realloc(void *oldBuffer, size_t oldSize, size_t newSize,
-                    unsigned long alignment);
-
-
 #ifdef __cplusplus
 }
 #endif
diff --git a/src/mesa/math/m_debug_norm.c b/src/mesa/math/m_debug_norm.c
index 8be07eecbe3..dccbdad4dd6 100644
--- a/src/mesa/math/m_debug_norm.c
+++ b/src/mesa/math/m_debug_norm.c
@@ -30,7 +30,6 @@
 #include "main/glheader.h"
 #include "main/context.h"
 #include "main/macros.h"
-#include "main/imports.h"
 
 #include "m_matrix.h"
 #include "m_xform.h"
@@ -209,7 +208,7 @@ static int test_norm_function( normal_func func, int mtype, long *cycles )
 
    (void) cycles;
 
-   mat->m = _mesa_align_malloc( 16 * sizeof(GLfloat), 16 );
+   mat->m = align_malloc( 16 * sizeof(GLfloat), 16 );
    mat->inv = m = mat->m;
 
    init_matrix( m );
@@ -328,7 +327,7 @@ static int test_norm_function( normal_func func, int mtype, long *cycles )
       }
    }
 
-   _mesa_align_free( mat->m );
+   align_free( mat->m );
    return 1;
 }
 
diff --git a/src/mesa/math/m_debug_xform.c b/src/mesa/math/m_debug_xform.c
index 632c82ea258..4795df286d6 100644
--- a/src/mesa/math/m_debug_xform.c
+++ b/src/mesa/math/m_debug_xform.c
@@ -29,7 +29,6 @@
 #include "main/glheader.h"
 #include "main/context.h"
 #include "main/macros.h"
-#include "main/imports.h"
 
 #include "m_matrix.h"
 #include "m_xform.h"
@@ -183,7 +182,7 @@ static int test_transform_function( transform_func func, int psize,
       return 0;
    }
 
-   mat->m = _mesa_align_malloc( 16 * sizeof(GLfloat), 16 );
+   mat->m = align_malloc( 16 * sizeof(GLfloat), 16 );
    mat->type = mtypes[mtype];
 
    m = mat->m;
@@ -273,7 +272,7 @@ static int test_transform_function( transform_func func, int psize,
       }
    }
 
-   _mesa_align_free( mat->m );
+   align_free( mat->m );
    return 1;
 }
 
diff --git a/src/mesa/math/m_matrix.c b/src/mesa/math/m_matrix.c
index 57a49533de2..65b4c4c28f5 100644
--- a/src/mesa/math/m_matrix.c
+++ b/src/mesa/math/m_matrix.c
@@ -37,11 +37,12 @@
 #include "c99_math.h"
 #include "main/errors.h"
 #include "main/glheader.h"
-#include "main/imports.h"
 #include "main/macros.h"
 
 #include "m_matrix.h"
 
+#include "util/u_memory.h"
+
 
 /**
  * \defgroup MatFlags MAT_FLAG_XXX-flags
@@ -1470,10 +1471,10 @@ _math_matrix_loadf( GLmatrix *mat, const GLfloat *m )
 void
 _math_matrix_ctr( GLmatrix *m )
 {
-   m->m = _mesa_align_malloc( 16 * sizeof(GLfloat), 16 );
+   m->m = align_malloc( 16 * sizeof(GLfloat), 16 );
    if (m->m)
       memcpy( m->m, Identity, sizeof(Identity) );
-   m->inv = _mesa_align_malloc( 16 * sizeof(GLfloat), 16 );
+   m->inv = align_malloc( 16 * sizeof(GLfloat), 16 );
    if (m->inv)
       memcpy( m->inv, Identity, sizeof(Identity) );
    m->type = MATRIX_IDENTITY;
@@ -1490,10 +1491,10 @@ _math_matrix_ctr( GLmatrix *m )
 void
 _math_matrix_dtr( GLmatrix *m )
 {
-   _mesa_align_free( m->m );
+   align_free( m->m );
    m->m = NULL;
 
-   _mesa_align_free( m->inv );
+   align_free( m->inv );
    m->inv = NULL;
 }
 
diff --git a/src/mesa/math/m_vector.c b/src/mesa/math/m_vector.c
index 831f953d655..cf113ad338b 100644
--- a/src/mesa/math/m_vector.c
+++ b/src/mesa/math/m_vector.c
@@ -29,11 +29,12 @@
 #include <stdio.h>
 
 #include "main/glheader.h"
-#include "main/imports.h"
 #include "main/macros.h"
 
 #include "m_vector.h"
 
+#include "util/u_memory.h"
+
 
 
 /**
@@ -101,7 +102,7 @@ _mesa_vector4f_alloc( GLvector4f *v, GLbitfield flags, GLuint count,
 {
    v->stride = 4 * sizeof(GLfloat);
    v->size = 2;
-   v->storage = _mesa_align_malloc( count * 4 * sizeof(GLfloat), alignment );
+   v->storage = align_malloc( count * 4 * sizeof(GLfloat), alignment );
    v->storage_count = count;
    v->start = (GLfloat *) v->storage;
    v->data = (GLfloat (*)[4]) v->storage;
@@ -119,7 +120,7 @@ void
 _mesa_vector4f_free( GLvector4f *v )
 {
    if (v->flags & VEC_MALLOC) {
-      _mesa_align_free( v->storage );
+      align_free( v->storage );
       v->data = NULL;
       v->start = NULL;
       v->storage = NULL;
diff --git a/src/mesa/program/prog_parameter.c b/src/mesa/program/prog_parameter.c
index 26904575bd6..ea135f28dff 100644
--- a/src/mesa/program/prog_parameter.c
+++ b/src/mesa/program/prog_parameter.c
@@ -30,7 +30,6 @@
 
 
 #include "main/glheader.h"
-#include "main/imports.h"
 #include "main/macros.h"
 #include "util/u_memory.h"
 #include "prog_instruction.h"
@@ -155,12 +154,12 @@ _mesa_new_parameter_list_sized(unsigned size)
       p->ParameterValueOffset = (unsigned *) calloc(size, sizeof(unsigned));
 
       p->ParameterValues = (gl_constant_value *)
-         _mesa_align_malloc(size * 4 *sizeof(gl_constant_value), 16);
+         align_malloc(size * 4 *sizeof(gl_constant_value), 16);
 
 
       if ((p->Parameters == NULL) || (p->ParameterValues == NULL)) {
          free(p->Parameters);
-         _mesa_align_free(p->ParameterValues);
+         align_free(p->ParameterValues);
          free(p);
          p = NULL;
       }
@@ -182,7 +181,7 @@ _mesa_free_parameter_list(struct gl_program_parameter_list *paramList)
    }
    free(paramList->Parameters);
    free(paramList->ParameterValueOffset);
-   _mesa_align_free(paramList->ParameterValues);
+   align_free(paramList->ParameterValues);
    free(paramList);
 }
 
@@ -214,10 +213,10 @@ _mesa_reserve_parameter_storage(struct gl_program_parameter_list *paramList,
                  paramList->Size * sizeof(unsigned));
 
       paramList->ParameterValues = (gl_constant_value *)
-         _mesa_align_realloc(paramList->ParameterValues,         /* old buf */
-                             oldNum * 4 * sizeof(gl_constant_value),/* old sz */
-                             paramList->Size*4*sizeof(gl_constant_value),/*new*/
-                             16);
+         align_realloc(paramList->ParameterValues,         /* old buf */
+                       oldNum * 4 * sizeof(gl_constant_value),/* old sz */
+                       paramList->Size*4*sizeof(gl_constant_value),/*new*/
+                       16);
    }
 }
 
diff --git a/src/mesa/swrast/s_texture.c b/src/mesa/swrast/s_texture.c
index 88b4e87c62a..7228d2e0e0d 100644
--- a/src/mesa/swrast/s_texture.c
+++ b/src/mesa/swrast/s_texture.c
@@ -100,7 +100,7 @@ _swrast_alloc_texture_image_buffer(struct gl_context *ctx,
                                            _swrast_teximage_slice_height(texImage), 1);
 
    assert(!swImg->Buffer);
-   swImg->Buffer = _mesa_align_malloc(bytesPerSlice * slices, 512);
+   swImg->Buffer = align_malloc(bytesPerSlice * slices, 512);
    if (!swImg->Buffer)
       return GL_FALSE;
 
@@ -166,7 +166,7 @@ _swrast_free_texture_image_buffer(struct gl_context *ctx,
 {
    struct swrast_texture_image *swImage = swrast_texture_image(texImage);
 
-   _mesa_align_free(swImage->Buffer);
+   align_free(swImage->Buffer);
    swImage->Buffer = NULL;
 
    free(swImage->ImageSlices);
diff --git a/src/mesa/tnl/t_vb_program.c b/src/mesa/tnl/t_vb_program.c
index 3c760382acf..a674f0a05e0 100644
--- a/src/mesa/tnl/t_vb_program.c
+++ b/src/mesa/tnl/t_vb_program.c
@@ -33,7 +33,6 @@
 
 #include "main/glheader.h"
 #include "main/macros.h"
-#include "main/imports.h"
 #include "main/samplerobj.h"
 #include "main/state.h"
 #include "math/m_xform.h"
@@ -42,6 +41,7 @@
 #include "program/prog_execute.h"
 #include "swrast/s_context.h"
 #include "util/bitscan.h"
+#include "util/u_memory.h"
 
 #include "tnl/tnl.h"
 #include "tnl/t_context.h"
@@ -481,7 +481,7 @@ init_vp(struct gl_context *ctx, struct tnl_pipeline_stage *stage)
 
    /* a few other misc allocations */
    _mesa_vector4f_alloc( &store->ndcCoords, 0, size, 32 );
-   store->clipmask = _mesa_align_malloc(sizeof(GLubyte)*size, 32 );
+   store->clipmask = align_malloc(sizeof(GLubyte)*size, 32 );
 
    return GL_TRUE;
 }
@@ -504,7 +504,7 @@ dtr(struct tnl_pipeline_stage *stage)
 
       /* free misc arrays */
       _mesa_vector4f_free( &store->ndcCoords );
-      _mesa_align_free( store->clipmask );
+      align_free( store->clipmask );
 
       free( store );
       stage->privatePtr = NULL;
diff --git a/src/mesa/tnl/t_vb_vertex.c b/src/mesa/tnl/t_vb_vertex.c
index 4fb3659a358..19f4beda564 100644
--- a/src/mesa/tnl/t_vb_vertex.c
+++ b/src/mesa/tnl/t_vb_vertex.c
@@ -28,12 +28,12 @@
 
 #include "main/glheader.h"
 #include "main/macros.h"
-#include "main/imports.h"
 #include "main/mtypes.h"
 
 #include "math/m_xform.h"
 
 #include "util/bitscan.h"
+#include "util/u_memory.h"
 
 #include "t_context.h"
 #include "t_pipeline.h"
@@ -247,7 +247,7 @@ static GLboolean init_vertex_stage( struct gl_context *ctx,
    _mesa_vector4f_alloc( &store->clip, 0, size, 32 );
    _mesa_vector4f_alloc( &store->proj, 0, size, 32 );
 
-   store->clipmask = _mesa_align_malloc(sizeof(GLubyte)*size, 32 );
+   store->clipmask = align_malloc(sizeof(GLubyte)*size, 32 );
 
    if (!store->clipmask ||
        !store->eye.data ||
@@ -266,7 +266,7 @@ static void dtr( struct tnl_pipeline_stage *stage )
       _mesa_vector4f_free( &store->eye );
       _mesa_vector4f_free( &store->clip );
       _mesa_vector4f_free( &store->proj );
-      _mesa_align_free( store->clipmask );
+      align_free( store->clipmask );
       free(store);
       stage->privatePtr = NULL;
       stage->run = init_vertex_stage;
diff --git a/src/mesa/tnl/t_vertex.c b/src/mesa/tnl/t_vertex.c
index baea953b88f..0d29403a846 100644
--- a/src/mesa/tnl/t_vertex.c
+++ b/src/mesa/tnl/t_vertex.c
@@ -512,7 +512,7 @@ void _tnl_init_vertices( struct gl_context *ctx,
    if (max_vertex_size > vtx->max_vertex_size) {
       _tnl_free_vertices( ctx );
       vtx->max_vertex_size = max_vertex_size;
-      vtx->vertex_buf = _mesa_align_calloc(vb_size * max_vertex_size, 32 );
+      vtx->vertex_buf = align_calloc(vb_size * max_vertex_size, 32 );
       invalidate_funcs(vtx);
    }
 
@@ -558,7 +558,7 @@ void _tnl_free_vertices( struct gl_context *ctx )
       struct tnl_clipspace *vtx = GET_VERTEX_STATE(ctx);
       struct tnl_clipspace_fastpath *fp, *tmp;
 
-      _mesa_align_free(vtx->vertex_buf);
+      align_free(vtx->vertex_buf);
       vtx->vertex_buf = NULL;
 
       for (fp = vtx->fastpath ; fp ; fp = tmp) {
diff --git a/src/mesa/vbo/vbo_exec_api.c b/src/mesa/vbo/vbo_exec_api.c
index 24bd1f0ba14..2770cbcd30e 100644
--- a/src/mesa/vbo/vbo_exec_api.c
+++ b/src/mesa/vbo/vbo_exec_api.c
@@ -43,6 +43,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "main/draw_validate.h"
 #include "main/dispatch.h"
 #include "util/bitscan.h"
+#include "util/u_memory.h"
 
 #include "vbo_noop.h"
 #include "vbo_private.h"
@@ -1125,7 +1126,7 @@ vbo_use_buffer_objects(struct gl_context *ctx)
    /* Make sure this func is only used once */
    assert(exec->vtx.bufferobj == ctx->Shared->NullBufferObj);
 
-   _mesa_align_free(exec->vtx.buffer_map);
+   align_free(exec->vtx.buffer_map);
    exec->vtx.buffer_map = NULL;
    exec->vtx.buffer_ptr = NULL;
 
@@ -1171,7 +1172,7 @@ vbo_exec_vtx_init(struct vbo_exec_context *exec)
                                  ctx->Shared->NullBufferObj);
 
    assert(!exec->vtx.buffer_map);
-   exec->vtx.buffer_map = _mesa_align_malloc(VBO_VERT_BUFFER_SIZE, 64);
+   exec->vtx.buffer_map = align_malloc(VBO_VERT_BUFFER_SIZE, 64);
    exec->vtx.buffer_ptr = exec->vtx.buffer_map;
 
    vbo_exec_vtxfmt_init(exec);
@@ -1205,7 +1206,7 @@ vbo_exec_vtx_destroy(struct vbo_exec_context *exec)
       assert(exec->vtx.bufferobj->Name == 0 ||
              exec->vtx.bufferobj->Name == IMM_BUFFER_NAME);
       if (exec->vtx.bufferobj->Name == 0) {
-         _mesa_align_free(exec->vtx.buffer_map);
+         align_free(exec->vtx.buffer_map);
          exec->vtx.buffer_map = NULL;
          exec->vtx.buffer_ptr = NULL;
       }
-- 
2.19.1



More information about the mesa-dev mailing list