X-Git-Url: https://pd.if.org/git/?a=blobdiff_plain;f=functions%2Fstdlib%2Frealloc.c;h=c1ba38f4d1cd2b674aa0ae5013ff0ebf54070379;hb=b08f4b52b1cd1f7a9553c0f357a7c90859fa3e73;hp=df5fca1bc75904411404315cac347ea32f8d164c;hpb=137bef7f4838fc430682213fa628e16b2237ed63;p=pdclib diff --git a/functions/stdlib/realloc.c b/functions/stdlib/realloc.c index df5fca1..c1ba38f 100644 --- a/functions/stdlib/realloc.c +++ b/functions/stdlib/realloc.c @@ -1,7 +1,5 @@ /* $Id$ */ -/* Release $Name$ */ - /* void * realloc( void *, size_t ) This file is part of the Public Domain C Library (PDCLib). @@ -18,6 +16,11 @@ void * realloc( void * ptr, size_t size ) { + if ( ptr == NULL ) + { + return malloc( size ); + } + { struct _PDCLIB_memnode_t * baseptr = (struct _PDCLIB_memnode_t *)( (char *)ptr - sizeof( struct _PDCLIB_memnode_t ) ); if ( baseptr->size >= size ) { @@ -30,6 +33,7 @@ void * realloc( void * ptr, size_t size ) free( ptr ); return newptr; } + } return NULL; } @@ -38,9 +42,8 @@ void * realloc( void * ptr, size_t size ) #ifdef TEST #include <_PDCLIB_test.h> -int main() +int main( void ) { - BEGIN_TESTS; /* tests covered in malloc test driver */ return TEST_RESULTS; }