4.115
Last change
on this file since 4d73c38 was
4d73c38,
checked in by Sebastian Huber <sebastian.huber@…>, on 08/25/10 at 12:35:52
|
2010-08-25 Sebastian Huber <sebastian.huber@…>
PR 1672/cpukit
- score/include/rtems/score/heap.h, score/src/heap.c,
score/src/heapallocate.c, score/src/heapextend.c,
score/src/heapfree.c, score/src/heapresizeblock.c,
score/src/heapsizeofuserarea.c: Added heap protection in case
RTEMS_DEBUG is defined.
|
-
Property mode set to
100644
|
File size:
1.2 KB
|
Line | |
---|
1 | /** |
---|
2 | * @file |
---|
3 | * |
---|
4 | * @ingroup ScoreHeap |
---|
5 | * |
---|
6 | * @brief Heap Handler implementation. |
---|
7 | */ |
---|
8 | |
---|
9 | /* |
---|
10 | * COPYRIGHT (c) 1989-1999. |
---|
11 | * On-Line Applications Research Corporation (OAR). |
---|
12 | * |
---|
13 | * The license and distribution terms for this file may be |
---|
14 | * found in the file LICENSE in this distribution or at |
---|
15 | * http://www.rtems.com/license/LICENSE. |
---|
16 | * |
---|
17 | * $Id$ |
---|
18 | */ |
---|
19 | |
---|
20 | #if HAVE_CONFIG_H |
---|
21 | #include "config.h" |
---|
22 | #endif |
---|
23 | |
---|
24 | #include <rtems/system.h> |
---|
25 | #include <rtems/score/sysstate.h> |
---|
26 | #include <rtems/score/heap.h> |
---|
27 | |
---|
28 | bool _Heap_Size_of_alloc_area( |
---|
29 | Heap_Control *heap, |
---|
30 | void *alloc_begin_ptr, |
---|
31 | uintptr_t *alloc_size |
---|
32 | ) |
---|
33 | { |
---|
34 | uintptr_t const page_size = heap->page_size; |
---|
35 | uintptr_t const alloc_begin = (uintptr_t) alloc_begin_ptr; |
---|
36 | Heap_Block *block = _Heap_Block_of_alloc_area( alloc_begin, page_size ); |
---|
37 | Heap_Block *next_block = NULL; |
---|
38 | uintptr_t block_size = 0; |
---|
39 | |
---|
40 | if ( !_Heap_Is_block_in_heap( heap, block ) ) { |
---|
41 | return false; |
---|
42 | } |
---|
43 | |
---|
44 | block_size = _Heap_Block_size( block ); |
---|
45 | next_block = _Heap_Block_at( block, block_size ); |
---|
46 | |
---|
47 | if ( |
---|
48 | !_Heap_Is_block_in_heap( heap, next_block ) |
---|
49 | || !_Heap_Is_prev_used( next_block ) |
---|
50 | ) { |
---|
51 | return false; |
---|
52 | } |
---|
53 | |
---|
54 | *alloc_size = (uintptr_t) next_block + HEAP_ALLOC_BONUS - alloc_begin; |
---|
55 | |
---|
56 | return true; |
---|
57 | } |
---|
58 | |
---|
Note: See
TracBrowser
for help on using the repository browser.