added _mesa_realloc()

This commit is contained in:
Brian Paul
2003-04-08 02:22:41 +00:00
parent b8ca0172e7
commit 0cebd5822a
2 changed files with 16 additions and 4 deletions
+13 -2
View File
@@ -1,5 +1,3 @@
/* $Id: imports.c,v 1.33 2003/03/04 16:33:53 brianp Exp $ */
/*
* Mesa 3-D graphics library
* Version: 5.1
@@ -180,6 +178,19 @@ _mesa_align_free(void *ptr)
}
void *
_mesa_realloc(void *oldBuffer, size_t oldSize, size_t newSize)
{
const size_t copySize = (oldSize < newSize) ? oldSize : newSize;
void *newBuffer = _mesa_malloc(newSize);
if (newBuffer && copySize > 0)
_mesa_memcpy(newBuffer, oldBuffer, copySize);
if (oldBuffer)
_mesa_free(oldBuffer);
return newBuffer;
}
void *
_mesa_memcpy(void *dest, const void *src, size_t n)
{
+3 -2
View File
@@ -1,5 +1,3 @@
/* $Id: imports.h,v 1.20 2003/04/03 20:34:38 brianp Exp $ */
/*
* Mesa 3-D graphics library
* Version: 5.1
@@ -579,6 +577,9 @@ _mesa_align_calloc( size_t bytes, unsigned long alignment );
extern void
_mesa_align_free( void *ptr );
extern void *
_mesa_realloc( void *oldBuffer, size_t oldSize, size_t newSize );
extern void *
_mesa_memcpy( void *dest, const void *src, size_t n );