4.11

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.org/license/LICENSE. |
---|

16 | */ |
---|

17 | |
---|

18 | #if HAVE_CONFIG_H |
---|

19 | #include "config.h" |
---|

20 | #endif |
---|

21 | |
---|

22 | #include <rtems/system.h> |
---|

23 | #include <rtems/score/heapimpl.h> |
---|

24 | |
---|

25 | bool _Heap_Size_of_alloc_area( |
---|

26 | Heap_Control *heap, |
---|

27 | void *alloc_begin_ptr, |
---|

28 | uintptr_t *alloc_size |
---|

29 | ) |
---|

30 | { |
---|

31 | uintptr_t const page_size = heap->page_size; |
---|

32 | uintptr_t const alloc_begin = (uintptr_t) alloc_begin_ptr; |
---|

33 | Heap_Block *block = _Heap_Block_of_alloc_area( alloc_begin, page_size ); |
---|

34 | Heap_Block *next_block = NULL; |
---|

35 | uintptr_t block_size = 0; |
---|

36 | |
---|

37 | if ( !_Heap_Is_block_in_heap( heap, block ) ) { |
---|

38 | return false; |
---|

39 | } |
---|

40 | |
---|

41 | block_size = _Heap_Block_size( block ); |
---|

42 | next_block = _Heap_Block_at( block, block_size ); |
---|

43 | |
---|

44 | if ( |
---|

45 | !_Heap_Is_block_in_heap( heap, next_block ) |
---|

46 | || !_Heap_Is_prev_used( next_block ) |
---|

47 | ) { |
---|

48 | return false; |
---|

49 | } |
---|

50 | |
---|

51 | *alloc_size = (uintptr_t) next_block + HEAP_ALLOC_BONUS - alloc_begin; |
---|

52 | |
---|

53 | return true; |
---|

54 | } |
---|

55 | |
---|

**Note:** See

TracBrowser
for help on using the repository browser.