From 3436d1bf37a0c323f16dabeb30bdc97a2bc064b7 Mon Sep 17 00:00:00 2001 From: Elia Sulimanov Date: Wed, 19 Aug 2020 16:03:58 +0300 Subject: [PATCH] Done Heap API --- source/Cosmos.Core/Memory/Heap.cs | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/source/Cosmos.Core/Memory/Heap.cs b/source/Cosmos.Core/Memory/Heap.cs index 30862e887..4ba37612d 100644 --- a/source/Cosmos.Core/Memory/Heap.cs +++ b/source/Cosmos.Core/Memory/Heap.cs @@ -5,9 +5,15 @@ using Native = System.UInt32; namespace Cosmos.Core.Memory { - + /// + /// Heap class. + /// public static unsafe class Heap { + /// + /// Init heap. + /// + /// Thrown on fatal error, contact support. public static void Init() { HeapSmall.Init(); @@ -15,6 +21,11 @@ namespace Cosmos.Core.Memory HeapLarge.Init(); } + /// + /// Alloc memory block, of a given size. + /// + /// A size of block to alloc, in bytes. + /// Byte pointer to the start of the block. public static byte* Alloc(Native aSize) { if (aSize <= HeapSmall.mMaxItemSize) @@ -33,6 +44,16 @@ namespace Cosmos.Core.Memory // Keep as void* and not byte* or other. Reduces typecasting from callers // who may have typed the pointer to their own needs. + /// + /// Free a heap item. + /// + /// A pointer to the heap item to be freed. + /// Thrown if: + /// + /// Page type is not found. + /// Heap item not found in RAT. + /// + /// public static void Free(void* aPtr) { //TODO find a better way to remove the double look up here for GetPageType and then again in the