gwnavruntime/kernel/HeapMH/HeapMH_MemoryHeap.h Source File

HeapMH_MemoryHeap.h
Go to the documentation of this file.
1 /*
2 * Copyright 2016 Autodesk, Inc. All rights reserved.
3 * Use of this software is subject to the terms of the Autodesk license agreement and any attachments or Appendices thereto provided at the time of installation or download,
4 * or which otherwise accompanies this software in either electronic or hard copy form, or which is signed by you and accepted by Autodesk.
5 */
6 
7 /**************************************************************************
8 
9 PublicHeader: Kernel
10 Filename : HeapMH_MemoryHeap.h
11 Content : Public memory heap class declaration, MagicHeader engine.
12 Created : October 1, 2008
13 Authors : Michael Antonov, Maxim Shemanarev
14 
15 **************************************************************************/
16 
17 #pragma once
18 
20 
21 namespace Kaim {
22 
23 // *** Predeclarations
24 //------------------------------------------------------------------------
25 namespace HeapMH
26 {
27  class RootMH;
28  class AllocEngineMH;
29  class DebugStorageMH;
30  struct PageMH;
31  struct NodeMH;
32  struct PageInfoMH;
33 }
34 
35 // ***** MemoryHeap
36 //------------------------------------------------------------------------
37 class MemoryHeapMH : public MemoryHeap
38 {
39 private:
40  friend class HeapMH::RootMH;
41 
42  MemoryHeapMH(); // Explicit creation and destruction is prohibited
43  virtual ~MemoryHeapMH() {}
44 
45 public:
46 
47  // *** Operations with memory arenas
48  //
49  //--------------------------------------------------------------------
50  virtual void DestroyArena(UPInt arena);
51  virtual bool ArenaIsEmpty(UPInt arena);
52 
53  // *** Initialization
54  //
55  // Creates a nested child heap; The heap should be destroyed
56  // by calling release. If child heap creation failed due to
57  // out-of-memory condition, returns 0. If child heap creation
58  // is not supported a pointer to the same parent heap will be returned.
59  //--------------------------------------------------------------------
60  virtual MemoryHeap* CreateHeap(const char* name,
61  const HeapDesc& desc);
62 
63  // *** Service functions
64  //--------------------------------------------------------------------
65 
66  virtual void SetLimitHandler(LimitHandler* handler);
67  virtual void SetLimit(UPInt newLimit);
68  virtual void AddRef();
69  virtual void Release();
70 
71  // *** Allocation API
72  //--------------------------------------------------------------------
73  virtual void* Alloc(UPInt size, const AllocInfo* info = 0);
74  virtual void* Alloc(UPInt size, UPInt align, const AllocInfo* info = 0);
75  virtual void* Realloc(void* oldPtr, UPInt newSize);
76  virtual void Free(void* ptr);
77  virtual void* AllocAutoHeap(const void *thisPtr, UPInt size,
78  const AllocInfo* info = 0);
79 
80  virtual void* AllocAutoHeap(const void *thisPtr, UPInt size, UPInt align,
81  const AllocInfo* info = 0);
82 
83  virtual MemoryHeap* GetAllocHeap(const void *thisPtr);
84 
85  virtual UPInt GetUsableSize(const void* ptr);
86 
87 
88  virtual void* AllocSysDirect(UPInt size);
89  virtual void FreeSysDirect(void* ptr, UPInt size);
90 
91  // *** Statistics
92  //--------------------------------------------------------------------
93  virtual UPInt GetFootprint() const;
94  virtual UPInt GetTotalFootprint() const;
95  virtual UPInt GetUsedSpace() const;
96  virtual UPInt GetTotalUsedSpace() const;
97  virtual void GetRootStats(RootStats* stats);
98  virtual void VisitMem(Heap::MemVisitor* visitor, unsigned flags);
99 
100  virtual void VisitRootSegments(Heap::SegVisitor* visitor);
101  virtual void VisitHeapSegments(Heap::SegVisitor* visitor) const;
102  virtual void SetTracer(HeapTracer* tracer);
103 
104 private:
105  //--------------------------------------------------------------------
106  virtual void destroyItself();
107  virtual void ultimateCheck();
108  virtual void releaseCachedMem();
109  virtual bool dumpMemoryLeaks();
110  virtual void checkIntegrity() const;
111  virtual void getUserDebugStats(RootStats* stats) const;
112 
113  void* allocMem(UPInt size, const AllocInfo* info);
114  void* allocMem(UPInt size, UPInt align, const AllocInfo* info);
115  void* allocMem(HeapMH::PageInfoMH* parentInfo, const void *thisPtr, UPInt size, const AllocInfo* info);
116  void* allocMem(HeapMH::PageInfoMH* parentInfo, const void *thisPtr, UPInt size, UPInt align, const AllocInfo* info);
117  void* reallocMem(HeapMH::PageMH* page, void* oldPtr, UPInt newSize);
118  void* reallocMem(HeapMH::NodeMH* node, void* oldPtr, UPInt newSize);
119 
120  void freeLocked(void* ptr);
121  void freeMem(HeapMH::PageMH* page, void* ptr);
122  void freeMem(HeapMH::NodeMH* node, void* ptr);
123 
124  //--------------------------------------------------------------------
125  HeapMH::AllocEngineMH* pEngine;
126  HeapMH::DebugStorageMH* pDebugStorage;
127 
128 public:
129  void* pUserData; // A small addition needed for Navigation.
130 };
131 
132 } // Scaleform
133 
The Autodesk Navigation namespace.
Definition: gamekitcrowddispersion.cpp:17