From 8ee939ea9f395f95357612d64d9be8e9a6529e46 Mon Sep 17 00:00:00 2001 From: Jeff Johnston Date: Wed, 19 Nov 2008 20:56:22 +0000 Subject: 2008-11-19 Jeff Johnston * libc/sys/linux/bits/dirent.h: New header file. * libc/sys/linux/sys/dirent.h: Include instead of . * libc/posix/Makefile.am: Remove reallocf. * libc/posix/Makefile.in: Regenerated. * libc/posix/reallocf.c: Moved to... * libc/stdlib/reallocf.c: Here * libc/stdlib/malloc.c: Add reallocf documentation. * libc/include/stdlib.h: Add reallocf and _reallocf_r prototypes. * libc/stdlib/Makefile.am: Add reallocf. * libc/stdlib/Makefile.in: Regenerated. * libc/posix/_isatty.c: Set errno. --- newlib/libc/stdlib/malloc.c | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) (limited to 'newlib/libc/stdlib/malloc.c') diff --git a/newlib/libc/stdlib/malloc.c b/newlib/libc/stdlib/malloc.c index 83453ab8d..160a13eff 100644 --- a/newlib/libc/stdlib/malloc.c +++ b/newlib/libc/stdlib/malloc.c @@ -22,6 +22,8 @@ INDEX malloc INDEX realloc +INDEX + reallocf INDEX free INDEX @@ -32,6 +34,8 @@ INDEX _malloc_r INDEX _realloc_r +INDEX + _reallocf_r INDEX _free_r INDEX @@ -43,6 +47,7 @@ ANSI_SYNOPSIS #include void *malloc(size_t <[nbytes]>); void *realloc(void *<[aptr]>, size_t <[nbytes]>); + void *reallocf(void *<[aptr]>, size_t <[nbytes]>); void free(void *<[aptr]>); void *memalign(size_t <[align]>, size_t <[nbytes]>); @@ -52,6 +57,8 @@ ANSI_SYNOPSIS void *_malloc_r(void *<[reent]>, size_t <[nbytes]>); void *_realloc_r(void *<[reent]>, void *<[aptr]>, size_t <[nbytes]>); + void *_reallocf_r(void *<[reent]>, + void *<[aptr]>, size_t <[nbytes]>); void _free_r(void *<[reent]>, void *<[aptr]>); void *_memalign_r(void *<[reent]>, @@ -68,6 +75,10 @@ TRAD_SYNOPSIS char *<[aptr]>; size_t <[nbytes]>; + char *reallocf(<[aptr]>, <[nbytes]>) + char *<[aptr]>; + size_t <[nbytes]>; + void free(<[aptr]>) char *<[aptr]>; @@ -87,6 +98,11 @@ TRAD_SYNOPSIS char *<[aptr]>; size_t <[nbytes]>; + char *_reallocf_r(<[reent]>, <[aptr]>, <[nbytes]>) + char *<[reent]>; + char *<[aptr]>; + size_t <[nbytes]>; + void _free_r(<[reent]>, <[aptr]>) char *<[reent]>; char *<[aptr]>; @@ -124,6 +140,11 @@ memory storage pool by calling <> with the address of the object as the argument. You can also use <> for this purpose by calling it with <<0>> as the <[nbytes]> argument. +The <> function behaves just like <> except if the +function is required to allocate new storage and this fails. In this +case <> will free the original object passed in whereas +<> will not. + The <> function returns a block of size <[nbytes]> aligned to a <[align]> boundary. The <[align]> argument must be a power of two. @@ -134,9 +155,9 @@ available in the block. This may or may not be more than the size requested from <>, due to alignment or minimum size constraints. -The alternate functions <<_malloc_r>>, <<_realloc_r>>, <<_free_r>>, -<<_memalign_r>>, and <<_malloc_usable_size_r>> are reentrant versions. -The extra argument <[reent]> is a pointer to a reentrancy structure. +The alternate functions <<_malloc_r>>, <<_realloc_r>>, <<_reallocf_r>>, +<<_free_r>>, <<_memalign_r>>, and <<_malloc_usable_size_r>> are reentrant +versions. The extra argument <[reent]> is a pointer to a reentrancy structure. If you have multiple threads of execution which may call any of these routines, or if any of these routines may be called reentrantly, then -- cgit v1.2.3