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

4.115
Last change on this file since 25f5730f was c499856, checked in by Chris Johns <chrisj@…>, on 03/20/14 at 21:10:47

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

  • Property mode set to 100644
File size: 1.2 KB
RevLine 
[dea3eccb]1/**
2 * @file
3 *
4 * @ingroup ScoreHeap
[93b4e6ef]5 *
[dea3eccb]6 * @brief Heap Handler implementation.
7 */
8
9/*
[08311cc3]10 *  COPYRIGHT (c) 1989-1999.
[93b4e6ef]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
[c499856]15 *  http://www.rtems.org/license/LICENSE.
[93b4e6ef]16 */
17
[a8eed23]18#if HAVE_CONFIG_H
19#include "config.h"
20#endif
[93b4e6ef]21
22#include <rtems/system.h>
[e6f7f81]23#include <rtems/score/heapimpl.h>
[93b4e6ef]24
[371cea31]25bool _Heap_Size_of_alloc_area(
26  Heap_Control *heap,
[dea3eccb]27  void *alloc_begin_ptr,
28  uintptr_t *alloc_size
[93b4e6ef]29)
30{
[dea3eccb]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 );
[371cea31]34  Heap_Block *next_block = NULL;
35  uintptr_t block_size = 0;
[93b4e6ef]36
[371cea31]37  if ( !_Heap_Is_block_in_heap( heap, block ) ) {
38    return false;
39  }
[93b4e6ef]40
[371cea31]41  block_size = _Heap_Block_size( block );
42  next_block = _Heap_Block_at( block, block_size );
[93b4e6ef]43
[962e894f]44  if (
[dea3eccb]45    !_Heap_Is_block_in_heap( heap, next_block )
46      || !_Heap_Is_prev_used( next_block )
[371cea31]47  ) {
48    return false;
49  }
[962e894f]50
[4d73c38]51  *alloc_size = (uintptr_t) next_block + HEAP_ALLOC_BONUS - alloc_begin;
[962e894f]52
[371cea31]53  return true;
[93b4e6ef]54}
[fff1b20]55
Note: See TracBrowser for help on using the repository browser.