X-Git-Url: https://pd.if.org/git/?p=pdclib;a=blobdiff_plain;f=opt%2Fmalloc-solar%2Frealloc.c;fp=opt%2Fmalloc-solar%2Frealloc.c;h=0000000000000000000000000000000000000000;hp=a7cc395d21a9f39d3669e4c7f4637c13f643c451;hb=81b6302395f77a0d4e0771cb9e1cef80188d9474;hpb=d7f375a09a9912bb18ad42f1442fbf64311bfed6 diff --git a/opt/malloc-solar/realloc.c b/opt/malloc-solar/realloc.c deleted file mode 100644 index a7cc395..0000000 --- a/opt/malloc-solar/realloc.c +++ /dev/null @@ -1,56 +0,0 @@ -/* void * realloc( void *, size_t ) - - This file is part of the Public Domain C Library (PDCLib). - Permission is granted to use, modify, and / or redistribute at will. -*/ - -#include -#include -#include - -#ifndef REGTEST - -/* TODO: Primitive placeholder. Improve. */ - -void * realloc( void * ptr, size_t size ) -{ - void * newptr = NULL; - if ( ptr == NULL ) - { - return malloc( size ); - } - if ( size > 0 ) - { - 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 ); - } - } - free( ptr ); - return newptr; -} - -#endif - -#ifdef TEST -#include <_PDCLIB_test.h> - -int main( void ) -{ - /* tests covered in malloc test driver */ - return TEST_RESULTS; -} - -#endif -