summaryrefslogtreecommitdiffstats
path: root/cpukit/libcsupport/src/malloc.c
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>2007-09-07 21:42:14 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>2007-09-07 21:42:14 +0000
commit1f49f77158e7e57da2a463fec248f7ebb3a2449e (patch)
tree2ebe6f81966217f933bd1c00641e674bb7f73eec /cpukit/libcsupport/src/malloc.c
parent2007-09-07 Joel Sherrill <joel.sherrill@oarcorp.com> (diff)
downloadrtems-1f49f77158e7e57da2a463fec248f7ebb3a2449e.tar.bz2
2007-09-07 Joel Sherrill <joel.sherrill@oarcorp.com>
* libcsupport/src/malloc.c: If RTEMS_HEAP_DEBUG is defined, add heap walk on init, malloc, and free. The ability to walk the heap appears to disappeared during the rework of the C Program heap to skip the Region.
Diffstat (limited to 'cpukit/libcsupport/src/malloc.c')
-rw-r--r--cpukit/libcsupport/src/malloc.c23
1 files changed, 21 insertions, 2 deletions
diff --git a/cpukit/libcsupport/src/malloc.c b/cpukit/libcsupport/src/malloc.c
index 16d69025d0..7509001e82 100644
--- a/cpukit/libcsupport/src/malloc.c
+++ b/cpukit/libcsupport/src/malloc.c
@@ -64,8 +64,10 @@ void reportMallocError(const char *msg, struct mallocNode *mp)
static char cbuf[500];
ind += sprintf(cbuf+ind, "Malloc Error: %s\n", msg);
if ((mp->forw->back != mp) || (mp->back->forw != mp))
- ind += sprintf(cbuf+ind, "mp:0x%x mp->forw:0x%x mp->forw->back:0x%x mp->back:0x%x mp->back->forw:0x%x\n",
- mp, mp->forw, mp->forw->back, mp->back, mp->back->forw);
+ ind += sprintf(cbuf+ind,
+ "mp:0x%x mp->forw:0x%x mp->forw->back:0x%x "
+ "mp->back:0x%x mp->back->forw:0x%x\n",
+ mp, mp->forw, mp->forw->back, mp->back, mp->back->forw);
if (mp->memory != (mp + 1))
ind += sprintf(cbuf+ind, "mp+1:0x%x ", mp + 1);
ind += sprintf(cbuf+ind, "mp->memory:0x%x mp->size:%d\n", mp->memory, mp->size);
@@ -192,6 +194,15 @@ void RTEMS_Malloc_Initialize(
if ( !status )
rtems_fatal_error_occurred( status );
+ #if defined(RTEMS_HEAP_DEBUG)
+ if ( _Protected_heap_Walk( &RTEMS_Malloc_Heap, 0, FALSE ) ) {
+ printk( "Malloc heap not initialized correctly\n" );
+ rtems_print_buffer( start, 32 );
+ printk( "\n" );
+ rtems_print_buffer( (start + length) - 48, 48 );
+ rtems_fatal_error_occurred( RTEMS_NO_MEMORY );
+ }
+ #endif
#ifdef MALLOC_STATS
/* zero all the stats */
(void) memset( &rtems_malloc_stats, 0, sizeof(rtems_malloc_stats) );
@@ -216,6 +227,10 @@ void *malloc(
if ( !size )
return (void *) 0;
+ #if defined(RTEMS_HEAP_DEBUG)
+ _Protected_heap_Walk( &RTEMS_Malloc_Heap, 0, FALSE );
+ #endif
+
/*
* Do not attempt to allocate memory if in a critical section or ISR.
*/
@@ -429,6 +444,10 @@ void free(
if ( !ptr )
return;
+ #if defined(RTEMS_HEAP_DEBUG)
+ _Protected_heap_Walk( &RTEMS_Malloc_Heap, 0, FALSE );
+ #endif
+
/*
* Do not attempt to free memory if in a critical section or ISR.
*/