diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2012-02-10 10:36:26 +0100 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2012-02-10 10:42:58 +0100 |
commit | 28a08877ea961b0440b121b4617919136d6f342d (patch) | |
tree | c20ca716fad23ca298e98cf03bd8262150c8108e /cpukit/libcsupport/src/rtems_heap_greedy.c | |
parent | Moved empty test in front of busy tests (diff) | |
download | rtems-28a08877ea961b0440b121b4617919136d6f342d.tar.bz2 |
Added support functions for greedy heap allocation
Various tests must check program paths that result due to failed memory
allocations from the heap. To avoid tinkering with internal heap
structures throughout the test code these functions should be used.
Diffstat (limited to 'cpukit/libcsupport/src/rtems_heap_greedy.c')
-rw-r--r-- | cpukit/libcsupport/src/rtems_heap_greedy.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/cpukit/libcsupport/src/rtems_heap_greedy.c b/cpukit/libcsupport/src/rtems_heap_greedy.c new file mode 100644 index 0000000000..d363fe4d3b --- /dev/null +++ b/cpukit/libcsupport/src/rtems_heap_greedy.c @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2012 embedded brains GmbH. All rights reserved. + * + * embedded brains GmbH + * Obere Lagerstr. 30 + * 82178 Puchheim + * Germany + * <rtems@embedded-brains.de> + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.com/license/LICENSE. + */ + +#if HAVE_CONFIG_H + #include "config.h" +#endif + +#include "malloc_p.h" + +void *rtems_heap_greedy_allocate( size_t remaining_free_space ) +{ + void *opaque; + + _RTEMS_Lock_allocator(); + opaque = _Heap_Greedy_allocate( RTEMS_Malloc_Heap, remaining_free_space ); + _RTEMS_Unlock_allocator(); + + return opaque; +} + +void rtems_heap_greedy_free( void *opaque ) +{ + _RTEMS_Lock_allocator(); + _Heap_Greedy_free( RTEMS_Malloc_Heap, opaque ); + _RTEMS_Unlock_allocator(); +} |