source: rtems/cpukit/libcsupport/src/rtems_heap_greedy.c @ e22af78

4.115
Last change on this file since e22af78 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
Line 
1/**
2 *  @file
3 *
4 *  @brief Greedy Allocate that Empties the Heap
5 *  @ingroup MallocSupport
6 */
7
8/*
9 * Copyright (c) 2012 embedded brains GmbH.  All rights reserved.
10 *
11 *  embedded brains GmbH
12 *  Obere Lagerstr. 30
13 *  82178 Puchheim
14 *  Germany
15 *  <rtems@embedded-brains.de>
16 *
17 * The license and distribution terms for this file may be
18 * found in the file LICENSE in this distribution or at
19 * http://www.rtems.org/license/LICENSE.
20 */
21
22#if HAVE_CONFIG_H
23  #include "config.h"
24#endif
25
26#include "malloc_p.h"
27
28void *rtems_heap_greedy_allocate(
29  const uintptr_t *block_sizes,
30  size_t block_count
31)
32{
33  void *opaque;
34
35  _RTEMS_Lock_allocator();
36  opaque = _Heap_Greedy_allocate( RTEMS_Malloc_Heap, block_sizes, block_count );
37  _RTEMS_Unlock_allocator();
38
39  return opaque;
40}
41
42void *rtems_heap_greedy_allocate_all_except_largest(
43  uintptr_t *allocatable_size
44)
45{
46  void *opaque;
47
48  _RTEMS_Lock_allocator();
49  opaque = _Heap_Greedy_allocate_all_except_largest(
50    RTEMS_Malloc_Heap,
51    allocatable_size
52  );
53  _RTEMS_Unlock_allocator();
54
55  return opaque;
56}
57
58void rtems_heap_greedy_free( void *opaque )
59{
60  _RTEMS_Lock_allocator();
61  _Heap_Greedy_free( RTEMS_Malloc_Heap, opaque );
62  _RTEMS_Unlock_allocator();
63}
Note: See TracBrowser for help on using the repository browser.