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

Last change on this file since 66cb142 was 1142f55, checked in by Sebastian Huber <sebastian.huber@…>, on Apr 8, 2016 at 4:56:46 AM

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
Line 
1/**
2 *  @file
3 *
4 *  @brief RTEMS Get Region Free Information
5 *  @ingroup ClassicRegion
6 */
7
8/*
9 *  COPYRIGHT (c) 1989-2014.
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
14 *  http://www.rtems.org/license/LICENSE.
15 */
16
17#if HAVE_CONFIG_H
18#include "config.h"
19#endif
20
21#include <rtems/rtems/regionimpl.h>
22
23#include <string.h>
24
25rtems_status_code rtems_region_get_free_information(
26  rtems_id                id,
27  Heap_Information_block *the_info
28)
29{
30  Region_Control *the_region;
31
32  if ( the_info == NULL ) {
33    return RTEMS_INVALID_ADDRESS;
34  }
35
36  the_region = _Region_Get_and_lock( id );
37
38  if ( the_region == NULL ) {
39    return RTEMS_INVALID_ID;
40  }
41
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;
47}
Note: See TracBrowser for help on using the repository browser.