From 0cebd5822a39ad3b3d7621f8e59efab329bfb5b9 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Tue, 8 Apr 2003 02:22:41 +0000 Subject: added _mesa_realloc() --- src/mesa/main/imports.c | 15 +++++++++++++-- src/mesa/main/imports.h | 5 +++-- 2 files changed, 16 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/mesa/main/imports.c b/src/mesa/main/imports.c index 8474ed4..a1c974c 100644 --- a/src/mesa/main/imports.c +++ b/src/mesa/main/imports.c @@ -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 @@ -181,6 +179,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) { #if defined(XFree86LOADER) && defined(IN_MODULE) diff --git a/src/mesa/main/imports.h b/src/mesa/main/imports.h index 51b19ba..5a42cfa 100644 --- a/src/mesa/main/imports.h +++ b/src/mesa/main/imports.h @@ -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 @@ -580,6 +578,9 @@ 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 ); extern void -- cgit v1.1