Index: c/src/exec/libcsupport/include/rtems/libcsupport.h
===================================================================
--- c/src/exec/libcsupport/include/rtems/libcsupport.h	(revision b541e1f8601c95c7952812ea8045cf2244848fd5)
+++ c/src/exec/libcsupport/include/rtems/libcsupport.h	(revision 3815a2b73c951c77f7e06f30837e95bcfe709ec8)
@@ -34,4 +34,5 @@
 extern int  host_errno(void);
 extern void fix_syscall_errno(void);
+extern size_t malloc_free_space();
 
 #ifdef __cplusplus
Index: c/src/exec/libcsupport/src/Makefile.am
===================================================================
--- c/src/exec/libcsupport/src/Makefile.am	(revision b541e1f8601c95c7952812ea8045cf2244848fd5)
+++ c/src/exec/libcsupport/src/Makefile.am	(revision 3815a2b73c951c77f7e06f30837e95bcfe709ec8)
@@ -38,5 +38,5 @@
     scandir.c seekdir.c telldir.c getcwd.c
 
-MALLOC_C_FILES = malloc.c __brk.c __sbrk.c
+MALLOC_C_FILES = malloc.c mallocfreespace.c __brk.c __sbrk.c
 
 PASSWORD_GROUP_C_FILES = getpwent.c getgrent.c
Index: c/src/exec/libcsupport/src/mallocfreespace.c
===================================================================
--- c/src/exec/libcsupport/src/mallocfreespace.c	(revision 3815a2b73c951c77f7e06f30837e95bcfe709ec8)
+++ c/src/exec/libcsupport/src/mallocfreespace.c	(revision 3815a2b73c951c77f7e06f30837e95bcfe709ec8)
@@ -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 <rtems.h>
+#include "libcsupport.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <assert.h>
+#include <errno.h>
+#include <string.h>
+
+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;
+}
Index: c/src/lib/ChangeLog
===================================================================
--- c/src/lib/ChangeLog	(revision b541e1f8601c95c7952812ea8045cf2244848fd5)
+++ c/src/lib/ChangeLog	(revision 3815a2b73c951c77f7e06f30837e95bcfe709ec8)
@@ -1,2 +1,9 @@
+
+2000-10-18	Joel Sherrill <joel@OARcorp.com>
+
+	* libc/Makefile.am: Added mallocfreespace.c.
+	* libc/mallocfreespace.c: New file based on work by Nick Simon
+	<Nick.SIMON@syntegra.bt.co.uk> which he included in malloc.c.
+	* libc/libcsupport.h: Added prototype for malloc_free_space().
 
 2000-10-18	Joel Sherrill <joel@OARcorp.com>
Index: c/src/lib/include/rtems/libcsupport.h
===================================================================
--- c/src/lib/include/rtems/libcsupport.h	(revision b541e1f8601c95c7952812ea8045cf2244848fd5)
+++ c/src/lib/include/rtems/libcsupport.h	(revision 3815a2b73c951c77f7e06f30837e95bcfe709ec8)
@@ -34,4 +34,5 @@
 extern int  host_errno(void);
 extern void fix_syscall_errno(void);
+extern size_t malloc_free_space();
 
 #ifdef __cplusplus
Index: c/src/lib/libc/Makefile.am
===================================================================
--- c/src/lib/libc/Makefile.am	(revision b541e1f8601c95c7952812ea8045cf2244848fd5)
+++ c/src/lib/libc/Makefile.am	(revision 3815a2b73c951c77f7e06f30837e95bcfe709ec8)
@@ -38,5 +38,5 @@
     scandir.c seekdir.c telldir.c getcwd.c
 
-MALLOC_C_FILES = malloc.c __brk.c __sbrk.c
+MALLOC_C_FILES = malloc.c mallocfreespace.c __brk.c __sbrk.c
 
 PASSWORD_GROUP_C_FILES = getpwent.c getgrent.c
Index: c/src/lib/libc/libcsupport.h
===================================================================
--- c/src/lib/libc/libcsupport.h	(revision b541e1f8601c95c7952812ea8045cf2244848fd5)
+++ c/src/lib/libc/libcsupport.h	(revision 3815a2b73c951c77f7e06f30837e95bcfe709ec8)
@@ -34,4 +34,5 @@
 extern int  host_errno(void);
 extern void fix_syscall_errno(void);
+extern size_t malloc_free_space();
 
 #ifdef __cplusplus
Index: c/src/lib/libc/mallocfreespace.c
===================================================================
--- c/src/lib/libc/mallocfreespace.c	(revision 3815a2b73c951c77f7e06f30837e95bcfe709ec8)
+++ c/src/lib/libc/mallocfreespace.c	(revision 3815a2b73c951c77f7e06f30837e95bcfe709ec8)
@@ -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 <rtems.h>
+#include "libcsupport.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <assert.h>
+#include <errno.h>
+#include <string.h>
+
+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;
+}
Index: cpukit/libcsupport/include/rtems/libcsupport.h
===================================================================
--- cpukit/libcsupport/include/rtems/libcsupport.h	(revision b541e1f8601c95c7952812ea8045cf2244848fd5)
+++ cpukit/libcsupport/include/rtems/libcsupport.h	(revision 3815a2b73c951c77f7e06f30837e95bcfe709ec8)
@@ -34,4 +34,5 @@
 extern int  host_errno(void);
 extern void fix_syscall_errno(void);
+extern size_t malloc_free_space();
 
 #ifdef __cplusplus
Index: cpukit/libcsupport/src/mallocfreespace.c
===================================================================
--- cpukit/libcsupport/src/mallocfreespace.c	(revision 3815a2b73c951c77f7e06f30837e95bcfe709ec8)
+++ cpukit/libcsupport/src/mallocfreespace.c	(revision 3815a2b73c951c77f7e06f30837e95bcfe709ec8)
@@ -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 <rtems.h>
+#include "libcsupport.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <assert.h>
+#include <errno.h>
+#include <string.h>
+
+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;
+}
