- void * newptr = malloc( size );
- memcpy( newptr, ptr, baseptr->size );
- free( ptr );
- return newptr;
+ struct _PDCLIB_memnode_t * baseptr = (struct _PDCLIB_memnode_t *)( (char *)ptr - sizeof( struct _PDCLIB_memnode_t ) );
+ if ( baseptr->size >= size )
+ {
+ /* Current memnode is large enough; nothing to do. */
+ return ptr;
+ }
+ else
+ {
+ /* Get larger memnode and copy over contents. */
+ if ( ( newptr = malloc( size ) ) == NULL )
+ {
+ return NULL;
+ }
+ memcpy( newptr, ptr, baseptr->size );
+ }