1 | /* |
---|
2 | * Heap Handler |
---|
3 | * |
---|
4 | * COPYRIGHT (c) 1989-1998. |
---|
5 | * On-Line Applications Research Corporation (OAR). |
---|
6 | * Copyright assigned to U.S. Government, 1994. |
---|
7 | * |
---|
8 | * The license and distribution terms for this file may be |
---|
9 | * found in the file LICENSE in this distribution or at |
---|
10 | * http://www.OARcorp.com/rtems/license.html. |
---|
11 | * |
---|
12 | * $Id$ |
---|
13 | */ |
---|
14 | |
---|
15 | |
---|
16 | #include <rtems/system.h> |
---|
17 | #include <rtems/score/sysstate.h> |
---|
18 | #include <rtems/score/heap.h> |
---|
19 | |
---|
20 | /*PAGE |
---|
21 | * |
---|
22 | * _Heap_Size_of_user_area |
---|
23 | * |
---|
24 | * This kernel routine returns the size of the memory area |
---|
25 | * given heap block. |
---|
26 | * |
---|
27 | * Input parameters: |
---|
28 | * the_heap - pointer to heap header |
---|
29 | * starting_address - starting address of the memory block to free. |
---|
30 | * size - pointer to size of area |
---|
31 | * |
---|
32 | * Output parameters: |
---|
33 | * size - size of area filled in |
---|
34 | * TRUE - if starting_address is valid heap address |
---|
35 | * FALSE - if starting_address is invalid heap address |
---|
36 | */ |
---|
37 | |
---|
38 | boolean _Heap_Size_of_user_area( |
---|
39 | Heap_Control *the_heap, |
---|
40 | void *starting_address, |
---|
41 | unsigned32 *size |
---|
42 | ) |
---|
43 | { |
---|
44 | Heap_Block *the_block; |
---|
45 | Heap_Block *next_block; |
---|
46 | unsigned32 the_size; |
---|
47 | |
---|
48 | the_block = _Heap_User_block_at( starting_address ); |
---|
49 | |
---|
50 | if ( !_Heap_Is_block_in( the_heap, the_block ) || |
---|
51 | _Heap_Is_block_free( the_block ) ) |
---|
52 | return( FALSE ); |
---|
53 | |
---|
54 | the_size = _Heap_Block_size( the_block ); |
---|
55 | next_block = _Heap_Block_at( the_block, the_size ); |
---|
56 | |
---|
57 | if ( !_Heap_Is_block_in( the_heap, next_block ) || |
---|
58 | (the_block->front_flag != next_block->back_flag) ) |
---|
59 | return( FALSE ); |
---|
60 | |
---|
61 | *size = the_size; |
---|
62 | return( TRUE ); |
---|
63 | } |
---|
64 | |
---|