X-Git-Url: https://pd.if.org/git/?a=blobdiff_plain;f=functions%2Fstdlib%2Frealloc.c;h=67133b4a790747926a71accabc4d92df32700c25;hb=d02f38605b53cdff5460cc6b9e1b2a80c3a2ba4c;hp=df5fca1bc75904411404315cac347ea32f8d164c;hpb=137bef7f4838fc430682213fa628e16b2237ed63;p=pdclib diff --git a/functions/stdlib/realloc.c b/functions/stdlib/realloc.c index df5fca1..67133b4 100644 --- a/functions/stdlib/realloc.c +++ b/functions/stdlib/realloc.c @@ -18,6 +18,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 +35,7 @@ void * realloc( void * ptr, size_t size ) free( ptr ); return newptr; } + } return NULL; } @@ -38,9 +44,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; }