From 1798d9a8a4a779746f5e665357b6bc10a2894d0b Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 24 May 2006 03:15:46 +0000 Subject: [PATCH] added _mesa_align_realloc() --- src/mesa/main/imports.c | 19 +++++++++++++++++++ src/mesa/main/imports.h | 4 ++++ 2 files changed, 23 insertions(+) diff --git a/src/mesa/main/imports.c b/src/mesa/main/imports.c index 5a986f2395e..b506f856a69 100644 --- a/src/mesa/main/imports.c +++ b/src/mesa/main/imports.c @@ -201,6 +201,25 @@ _mesa_align_free(void *ptr) #endif } +/** + * Reallocate memory, with alignment. + */ +void * +_mesa_align_realloc(void *oldBuffer, size_t oldSize, size_t newSize, + unsigned long alignment) +{ + const size_t copySize = (oldSize < newSize) ? oldSize : newSize; + void *newBuf = _mesa_align_malloc(newSize, alignment); + if (newBuf && oldBuffer && copySize > 0) { + _mesa_memcpy(newBuf, oldBuffer, copySize); + } + if (oldBuffer) + _mesa_align_free(oldBuffer); + return newBuf; +} + + + /** Reallocate memory */ void * _mesa_realloc(void *oldBuffer, size_t oldSize, size_t newSize) diff --git a/src/mesa/main/imports.h b/src/mesa/main/imports.h index 2827264a3ac..6eeb4841ba4 100644 --- a/src/mesa/main/imports.h +++ b/src/mesa/main/imports.h @@ -624,6 +624,10 @@ _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); + extern void * _mesa_exec_malloc( GLuint size ); -- 2.30.2