source: rtems/cpukit/score/src/heapsizeofuserarea.c @ 25f5730f

4.11
Last change on this file since 25f5730f was c499856, checked in by Chris Johns <chrisj@…>, on Mar 20, 2014 at 9:10:47 PM

Change all references of rtems.com to rtems.org.

  • 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.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
25bool _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.