X-Git-Url: https://pd.if.org/git/?a=blobdiff_plain;f=functions%2Fstdlib%2Frealloc.c;h=67133b4a790747926a71accabc4d92df32700c25;hb=12e17136786afb1775c9dc946cbe41f5e230c24a;hp=df5fca1bc75904411404315cac347ea32f8d164c;hpb=e802f3cc4c1e7f5b53adf9f3f5f9066195a145b6;p=pdclib.old 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; }