added _mesa_align_realloc()
authorBrian Paul <brian.paul@tungstengraphics.com>
Wed, 24 May 2006 03:15:46 +0000 (03:15 +0000)
committerBrian Paul <brian.paul@tungstengraphics.com>
Wed, 24 May 2006 03:15:46 +0000 (03:15 +0000)
src/mesa/main/imports.c
src/mesa/main/imports.h

index 5a986f2395ec2b247824933b9d49587c1794759b..b506f856a699ee8af54eefbdbb0938a9a71e0a3d 100644 (file)
@@ -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)
index 2827264a3ac7219d8b2e11366c44fcf80eec2531..6eeb4841ba449b2b7183d9181ae11b03dd2ab566 100644 (file)
@@ -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 );