1 /* void * realloc( void *, size_t )
3 This file is part of the Public Domain C Library (PDCLib).
4 Permission is granted to use, modify, and / or redistribute at will.
13 /* TODO: Primitive placeholder. Improve. */
15 void * realloc( void * ptr, size_t size )
20 return malloc( size );
24 struct _PDCLIB_memnode_t * baseptr = (struct _PDCLIB_memnode_t *)( (char *)ptr - sizeof( struct _PDCLIB_memnode_t ) );
25 if ( baseptr->size >= size )
27 /* Current memnode is large enough; nothing to do. */
32 /* Get larger memnode and copy over contents. */
33 if ( ( newptr = malloc( size ) ) == NULL )
37 memcpy( newptr, ptr, baseptr->size );
48 #include "_PDCLIB_test.h"
52 /* tests covered in malloc test driver */