diff options
author | Joel Sherrill <joel.sherrill@OARcorp.com> | 2009-09-06 15:24:08 +0000 |
---|---|---|
committer | Joel Sherrill <joel.sherrill@OARcorp.com> | 2009-09-06 15:24:08 +0000 |
commit | dea3eccb38b556b04552219e00b7abd656587278 (patch) | |
tree | 6affcb3026172273e366ee15ed3e8ec70f023a20 /cpukit/score/src/heapsizeofuserarea.c | |
parent | Regenerate. (diff) | |
download | rtems-dea3eccb38b556b04552219e00b7abd656587278.tar.bz2 |
2009-09-06 Sebastian Huber <Sebastian.Huber@embedded-brains.de>
* libcsupport/src/free.c, libmisc/stackchk/check.c,
rtems/include/rtems/rtems/region.h, rtems/src/regioncreate.c,
rtems/src/regionextend.c, rtems/src/regiongetinfo.c,
rtems/src/regiongetsegment.c, rtems/src/regiongetsegmentsize.c,
rtems/src/regionresizesegment.c, score/src/pheapallocate.c,
score/src/pheapallocatealigned.c, score/src/pheapextend.c,
score/src/pheapfree.c, score/src/pheapgetblocksize.c,
score/src/pheapgetfreeinfo.c, score/src/pheapgetinfo.c,
score/src/pheapgetsize.c, score/src/pheapinit.c,
score/src/pheapresizeblock.c, score/src/pheapwalk.c:
Update for heap API changes.
* score/include/rtems/score/apimutex.h,
score/include/rtems/score/object.h: Documentation.
* score/include/rtems/score/heap.h,
score/include/rtems/score/protectedheap.h,
score/inline/rtems/score/heap.inl, score/src/heap.c,
score/src/heapallocate.c, score/src/heapallocatealigned.c,
score/src/heapextend.c, score/src/heapfree.c,
score/src/heapgetfreeinfo.c, score/src/heapgetinfo.c,
score/src/heapresizeblock.c, score/src/heapsizeofuserarea.c,
score/src/heapwalk.c: Overall cleanup. Added boundary constraint to
allocation function. More changes follow.
Diffstat (limited to 'cpukit/score/src/heapsizeofuserarea.c')
-rw-r--r-- | cpukit/score/src/heapsizeofuserarea.c | 46 |
1 files changed, 16 insertions, 30 deletions
diff --git a/cpukit/score/src/heapsizeofuserarea.c b/cpukit/score/src/heapsizeofuserarea.c index be51255eee..7c297a77e6 100644 --- a/cpukit/score/src/heapsizeofuserarea.c +++ b/cpukit/score/src/heapsizeofuserarea.c @@ -1,6 +1,12 @@ -/* - * Heap Handler +/** + * @file + * + * @ingroup ScoreHeap * + * @brief Heap Handler implementation. + */ + +/* * COPYRIGHT (c) 1989-1999. * On-Line Applications Research Corporation (OAR). * @@ -21,24 +27,16 @@ bool _Heap_Size_of_alloc_area( Heap_Control *heap, - void *alloc_area_begin_ptr, - uintptr_t *size + void *alloc_begin_ptr, + uintptr_t *alloc_size ) { - uintptr_t alloc_area_begin = (uintptr_t) alloc_area_begin_ptr; - Heap_Block *block = - _Heap_Block_of_alloc_area( alloc_area_begin, heap->page_size ); + uintptr_t const page_size = heap->page_size; + uintptr_t const alloc_begin = (uintptr_t) alloc_begin_ptr; + Heap_Block *block = _Heap_Block_of_alloc_area( alloc_begin, page_size ); Heap_Block *next_block = NULL; uintptr_t block_size = 0; - if ( - !_Addresses_Is_in_range( alloc_area_begin_ptr, heap->start, heap->final ) - ) { - return false; - } - - - _HAssert(_Heap_Is_block_in_heap( heap, block )); if ( !_Heap_Is_block_in_heap( heap, block ) ) { return false; } @@ -46,26 +44,14 @@ bool _Heap_Size_of_alloc_area( block_size = _Heap_Block_size( block ); next_block = _Heap_Block_at( block, block_size ); - _HAssert( _Heap_Is_block_in_heap( heap, next_block )); - _HAssert( _Heap_Is_prev_used( next_block )); if ( - !_Heap_Is_block_in_heap( heap, next_block ) || - !_Heap_Is_prev_used( next_block ) + !_Heap_Is_block_in_heap( heap, next_block ) + || !_Heap_Is_prev_used( next_block ) ) { return false; } - /* - * 'alloc_area_begin' could be greater than 'block' address plus - * HEAP_BLOCK_ALLOC_AREA_OFFSET as _Heap_Allocate_aligned() may produce such - * user pointers. To get rid of this offset we calculate user size as - * difference between the end of 'block' (='next_block') and - * 'alloc_area_begin' and then add correction equal to the offset of the - * 'size' field of the 'Heap_Block' structure. The correction is due to the - * fact that 'prev_size' field of the next block is actually used as user - * accessible area of 'block'. - */ - *size = (uintptr_t) next_block - alloc_area_begin + HEAP_BLOCK_SIZE_OFFSET; + *alloc_size = (uintptr_t) next_block + HEAP_BLOCK_SIZE_OFFSET - alloc_begin; return true; } |