source: rtems/cpukit/rtems/src/regiongetfreeinfo.c @ 66cb142

5
Last change on this file since 66cb142 was 1142f55, checked in by Sebastian Huber <sebastian.huber@…>, on 04/08/16 at 04:56:46

rtems: Add and use _Region_Get_and_lock()

Get region and lock allocator in _Region_Get_and_lock() in case the
region exists and unlock it in _Region_Unlock().

  • Property mode set to 100644
File size: 968 bytes
RevLine 
[a6500136]1/**
2 *  @file
[9b3f187]3 *
[a6500136]4 *  @brief RTEMS Get Region Free Information
5 *  @ingroup ClassicRegion
6 */
7
8/*
[3a638ce]9 *  COPYRIGHT (c) 1989-2014.
[9b3f187]10 *  On-Line Applications Research Corporation (OAR).
11 *
12 *  The license and distribution terms for this file may be
13 *  found in the file LICENSE in this distribution or at
[c499856]14 *  http://www.rtems.org/license/LICENSE.
[9b3f187]15 */
16
[1095ec1]17#if HAVE_CONFIG_H
18#include "config.h"
19#endif
20
[f6c7c57d]21#include <rtems/rtems/regionimpl.h>
[572cb624]22
23#include <string.h>
[9b3f187]24
25rtems_status_code rtems_region_get_free_information(
[d3b72ca3]26  rtems_id                id,
[9b3f187]27  Heap_Information_block *the_info
28)
29{
[1142f55]30  Region_Control *the_region;
[9b3f187]31
[572cb624]32  if ( the_info == NULL ) {
[9b3f187]33    return RTEMS_INVALID_ADDRESS;
[572cb624]34  }
[9b3f187]35
[1142f55]36  the_region = _Region_Get_and_lock( id );
[9b3f187]37
[1142f55]38  if ( the_region == NULL ) {
39    return RTEMS_INVALID_ID;
[572cb624]40  }
[9b3f187]41
[1142f55]42  memset( &the_info->Used, 0, sizeof( the_info->Used ) );
43  _Heap_Get_free_information( &the_region->Memory, &the_info->Free );
44
45  _Region_Unlock( the_region );
46  return RTEMS_SUCCESSFUL;
[9b3f187]47}
Note: See TracBrowser for help on using the repository browser.