From 3815a2b73c951c77f7e06f30837e95bcfe709ec8 Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Wed, 18 Oct 2000 15:02:06 +0000 Subject: 2000-10-18 Joel Sherrill * libc/Makefile.am: Added mallocfreespace.c. * libc/mallocfreespace.c: New file based on work by Nick Simon which he included in malloc.c. * libc/libcsupport.h: Added prototype for malloc_free_space(). --- cpukit/libcsupport/include/rtems/libcsupport.h | 1 + cpukit/libcsupport/src/mallocfreespace.c | 40 ++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 cpukit/libcsupport/src/mallocfreespace.c (limited to 'cpukit') diff --git a/cpukit/libcsupport/include/rtems/libcsupport.h b/cpukit/libcsupport/include/rtems/libcsupport.h index 4c6764c1d4..4def1e82c5 100644 --- a/cpukit/libcsupport/include/rtems/libcsupport.h +++ b/cpukit/libcsupport/include/rtems/libcsupport.h @@ -33,6 +33,7 @@ extern void malloc_walk(size_t source, size_t printf_enabled); extern void libc_init(int reentrant); extern int host_errno(void); extern void fix_syscall_errno(void); +extern size_t malloc_free_space(); #ifdef __cplusplus } diff --git a/cpukit/libcsupport/src/mallocfreespace.c b/cpukit/libcsupport/src/mallocfreespace.c new file mode 100644 index 0000000000..28ef83278e --- /dev/null +++ b/cpukit/libcsupport/src/mallocfreespace.c @@ -0,0 +1,40 @@ +/* + * RTEMS Malloc Get Status Information + * + * + * COPYRIGHT (c) 1989-2000. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.OARcorp.com/rtems/license.html. + * + * $Id$ + */ + +#define __RTEMS_VIOLATE_KERNEL_VISIBILITY__ +#include +#include "libcsupport.h" + +#include +#include +#include +#include +#include +#include + +extern rtems_id RTEMS_Malloc_Heap; + +/* + * Find amount of free heap remaining + */ + +size_t malloc_free_space( void ) +{ + region_information_block heap_info; + + if ( region_get_information( RTEMS_Malloc_Heap, &heap_info ) ) { + return (size_t) heap_info.free_size; + } + return (size_t) -1; +} -- cgit v1.2.3