embkernel
 All Classes Functions Variables Typedefs Groups Pages
RtosHeap.hpp
1 //------------------------------------------------------------------------------
2 //This file is part of embKernel.
3 //See license.txt for the full license governing this code.
4 //------------------------------------------------------------------------------
8 #ifndef RTOS_HEAP_HPP_
9 #define RTOS_HEAP_HPP_
10 
11 #include "RtosMacros.hpp"
12 #include "RtosSemaphore.hpp"
13 #include "LibDmem.hpp"
14 
15 #include <stddef.h>
16 #include <stdint.h>
17 
23 class RtosHeap {
24 public:
25  static void* alloc(size_t size);
26  static void free(void* p);
27  static void* resize(void* p, size_t size);
28  void* resizeLeft(void* p, size_t left);
29  static size_t getTotalMemory();
30  static size_t getFreeMemory();
31  static unsigned int getBlockCount();
32 
33 private:
34  static bool sIsInitialized;
35  static uint8_t sSemaphoreLocation[sizeof(RtosSemaphore)];
36  static RtosSemaphore* sSemaphore;
37  static uint8_t sMemLocation[sizeof(LibDmem)];
38  static LibDmem* sMem;
39 };
40 
41 #endif /* RTOS_HEAP_HPP_ */
42