summaryrefslogtreecommitdiffstats
path: root/cpukit/score/src/heapfree.c
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>2007-07-11 20:56:10 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>2007-07-11 20:56:10 +0000
commit55d7626db75b1b5323aa5ba16b3cbc0a985462fe (patch)
treec4268b9ad2466b12170205743fd97d425da18e8a /cpukit/score/src/heapfree.c
parent2007-07-11 Joel Sherrill <joel.sherrill@oarcorp.com> (diff)
downloadrtems-55d7626db75b1b5323aa5ba16b3cbc0a985462fe.tar.bz2
2007-07-11 Joel Sherrill <joel.sherrill@oarcorp.com>
* libcsupport/src/malloc.c: Clean up Malloc debug code. * score/include/rtems/score/heap.h: Spacing. * score/inline/rtems/score/thread.inl: * score/src/heapfree.c. Clean up and add explicit check of the address being freed actually being in the heap. * score/src/heapwalk.c: Switch to printk and do not call abort.
Diffstat (limited to 'cpukit/score/src/heapfree.c')
-rw-r--r--cpukit/score/src/heapfree.c25
1 files changed, 15 insertions, 10 deletions
diff --git a/cpukit/score/src/heapfree.c b/cpukit/score/src/heapfree.c
index e0e2e72d85..30667036d6 100644
--- a/cpukit/score/src/heapfree.c
+++ b/cpukit/score/src/heapfree.c
@@ -1,7 +1,7 @@
/*
* Heap Handler
*
- * COPYRIGHT (c) 1989-1999.
+ * COPYRIGHT (c) 1989-2007.
* On-Line Applications Research Corporation (OAR).
*
* The license and distribution terms for this file may be
@@ -40,18 +40,23 @@ boolean _Heap_Free(
void *starting_address
)
{
- Heap_Block *the_block;
- Heap_Block *next_block;
+ Heap_Block *the_block;
+ Heap_Block *next_block;
uint32_t the_size;
uint32_t next_size;
Heap_Statistics *const stats = &the_heap->stats;
- boolean next_is_free;
+ boolean next_is_free;
+
+ if ( !_Addresses_Is_in_range(
+ starting_address, (void *)the_heap->start, (void *)the_heap->final ) ) {
+ _HAssert(starting_address != NULL);
+ return( FALSE );
+ }
_Heap_Start_of_block( the_heap, starting_address, &the_block );
if ( !_Heap_Is_block_in( the_heap, the_block ) ) {
- _HAssert(starting_address == NULL);
- _HAssert(FALSE);
+ _HAssert( FALSE );
return( FALSE );
}
@@ -59,12 +64,12 @@ boolean _Heap_Free(
next_block = _Heap_Block_at( the_block, the_size );
if ( !_Heap_Is_block_in( the_heap, next_block ) ) {
- _HAssert(FALSE);
+ _HAssert( FALSE );
return( FALSE );
}
if ( !_Heap_Is_prev_used( next_block ) ) {
- _HAssert(FALSE);
+ _HAssert( FALSE );
return( FALSE );
}
@@ -77,14 +82,14 @@ boolean _Heap_Free(
Heap_Block *const prev_block = _Heap_Block_at( the_block, -prev_size );
if ( !_Heap_Is_block_in( the_heap, prev_block ) ) {
- _HAssert(FALSE);
+ _HAssert( FALSE );
return( FALSE );
}
/* As we always coalesce free blocks, the block that preceedes prev_block
must have been used. */
if ( !_Heap_Is_prev_used ( prev_block) ) {
- _HAssert(FALSE);
+ _HAssert( FALSE );
return( FALSE );
}