X-Git-Url: https://pd.if.org/git/?a=blobdiff_plain;f=functions%2Fstdlib%2Frealloc.c;fp=functions%2Fstdlib%2Frealloc.c;h=0000000000000000000000000000000000000000;hb=7af1f0a20869ff41a951132d14bcc5f6b647fd07;hp=099ad5dd170ea1251c4562d62bf70a295102bcc6;hpb=97dd2fddbdb56005b16a1b0aa19ed15cd77269fc;p=pdclib.old diff --git a/functions/stdlib/realloc.c b/functions/stdlib/realloc.c deleted file mode 100644 index 099ad5d..0000000 --- a/functions/stdlib/realloc.c +++ /dev/null @@ -1,58 +0,0 @@ -/* $Id$ */ - -/* 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 -