summaryrefslogtreecommitdiffhomepage
path: root/SDK/Libraries/CoreSystem/Sources/Heap.c
diff options
context:
space:
mode:
authorAmlal <amlalelmahrouss@icloud.com>2024-06-06 10:27:55 +0000
committerAmlal <amlalelmahrouss@icloud.com>2024-06-06 10:27:55 +0000
commit4e75e05a20ddd0dbca982e8f3bc2ea8043ed3a3f (patch)
tree95409c0e32b644578b94a5c230417da684d79dc9 /SDK/Libraries/CoreSystem/Sources/Heap.c
parentf5081a8f9a8537ad5be5d639955cd1d0e68a9e1d (diff)
parent9994b8f3f88131f41be1061fb0947177e66dc7b0 (diff)
Merged in MHR-23 (pull request #14)
Draft: MHR-23
Diffstat (limited to 'SDK/Libraries/CoreSystem/Sources/Heap.c')
-rw-r--r--SDK/Libraries/CoreSystem/Sources/Heap.c54
1 files changed, 54 insertions, 0 deletions
diff --git a/SDK/Libraries/CoreSystem/Sources/Heap.c b/SDK/Libraries/CoreSystem/Sources/Heap.c
new file mode 100644
index 00000000..e7a77ba5
--- /dev/null
+++ b/SDK/Libraries/CoreSystem/Sources/Heap.c
@@ -0,0 +1,54 @@
+/* -------------------------------------------
+
+ Copyright SoftwareLabs
+
+------------------------------------------- */
+
+#include <Headers/Defines.h>
+#include <Headers/Heap.h>
+
+/// @brief Allocate from the user's heap.
+/// @param sz size of object.
+/// @param flags flags.
+/// @return
+CS_EXTERN_C PtrVoidType CSAllocateHeap(QWordType sz, DWordType flags)
+{
+ CS_MUST_PASS(kSharedApplication);
+ CS_MUST_PASS(sz);
+ CS_MUST_PASS(flags);
+
+ return (PtrVoidType)kSharedApplication->Invoke(kSharedApplication,
+ kCallAllocPtr, sz, flags);
+}
+
+/// @brief Free pointer from the user's heap.
+/// @param ptr the pointer to free.
+CS_EXTERN_C VoidType CSFreeHeap(PtrVoidType ptr)
+{
+ CS_MUST_PASS(kSharedApplication);
+ CS_MUST_PASS(ptr);
+
+ CS_UNREFERENCED_PARAMETER(
+ kSharedApplication->Invoke(kSharedApplication, kCallFreePtr, ptr));
+}
+
+/// @brief Get pointer size.
+/// @param ptr the pointer to find.
+/// @return the size.
+CS_EXTERN_C QWordType CSGetHeapSize(PtrVoidType ptr)
+{
+ CS_MUST_PASS(kSharedApplication);
+
+ CS_MUST_PASS(ptr);
+ return kSharedApplication->Invoke(kSharedApplication, kCallSizePtr, ptr);
+}
+
+/// @brief Check if the pointer exists.
+/// @param ptr the pointer to check.
+/// @return if it exists
+CS_EXTERN_C BooleanType CSIsHeapValid(PtrVoidType ptr)
+{
+ CS_MUST_PASS(kSharedApplication);
+ CS_MUST_PASS(ptr);
+ return kSharedApplication->Invoke(kSharedApplication, kCallCheckPtr, ptr);
+}