summaryrefslogtreecommitdiffstats
path: root/src/gallium
diff options
context:
space:
mode:
authorKeith Whitwell <[email protected]>2008-03-18 13:10:51 +0000
committerKeith Whitwell <[email protected]>2008-03-18 19:17:26 +0000
commit35a1ec53a7728311de22124c14b93dbbdee2ce90 (patch)
treecdf69d925873868c83a5498bff965e00beae6b5f /src/gallium
parent17b234ae3319d8a36afc44d0cceb30fea6b42d67 (diff)
gallium: make REALLOC a bit more like realloc
Diffstat (limited to 'src/gallium')
-rw-r--r--src/gallium/include/pipe/p_util.h16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/gallium/include/pipe/p_util.h b/src/gallium/include/pipe/p_util.h
index ef36ce75f7d..c2e0f8c6a5d 100644
--- a/src/gallium/include/pipe/p_util.h
+++ b/src/gallium/include/pipe/p_util.h
@@ -88,14 +88,16 @@ FREE( void *ptr )
static INLINE void *
REALLOC( void *old_ptr, unsigned old_size, unsigned new_size )
{
- void *new_ptr;
- if( new_size <= old_size ) {
- return old_ptr;
- }
- new_ptr = MALLOC( new_size );
- if( new_ptr ) {
- memcpy( new_ptr, old_ptr, old_size );
+ void *new_ptr = NULL;
+
+ if (new_size != 0) {
+ new_ptr = MALLOC( new_size );
+
+ if( new_ptr && old_ptr ) {
+ memcpy( new_ptr, old_ptr, old_size );
+ }
}
+
FREE( old_ptr );
return new_ptr;
}