Free Electron
Allocator.h
Go to the documentation of this file.
1 /* Copyright (C) 2003-2021 Free Electron Organization
2  Any use of this software requires a license. If a valid license
3  was not distributed with this file, visit freeelectron.org. */
4 
5 /** @file */
6 
7 #ifndef __core_Allocator_h__
8 #define __core_Allocator_h__
9 
10 namespace fe
11 {
12 
13 class Allocator : public Counted
14 {
15  public:
16 virtual ~Allocator(void) {}
17 virtual void *allocate(FE_UWORD byteCount) =0;
18 virtual void deallocate(void* pMemory) =0;
19 
20 #if FE_COUNTED_TRACK
21  Allocator(void): m_name("Allocator") {}
22 const String& name(void) const { return m_name; }
23  private:
24  String m_name;
25 #endif
26 };
27 
28 class BasicAllocator : public Allocator
29 {
30  public:
31 virtual ~BasicAllocator(void) {}
32 virtual void *allocate(FE_UWORD byteCount)
33  {
34  void *ptr = fe::allocate(byteCount);
35 // feLog("BasicAllocator::allocate %p\n",ptr);
36  return ptr;
37  }
38 virtual void deallocate(void* pMemory)
39  {
40  fe::deallocate(pMemory);
41  }
42 };
43 
44 } /* namespace */
45 
46 #endif /* __core_Allocator_h__ */
47 
kernel
Definition: namespace.dox:3