summaryrefslogtreecommitdiffhomepage
path: root/Public/Kits/System.Core/HeapAPI.hxx
blob: f50ff6f7d1accf9df24de4cbc1c8141924d04438 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/* -------------------------------------------

    Copyright Mahrouss Logic

------------------------------------------- */

#pragma once

#include <CompilerKit/CompilerKit.hxx>
#include <NewKit/Defines.hpp>

/// @brief SOM class, translated to C++

using namespace HCore;

namespace System {
class MemoryException;

typedef VoidPtr HeapPtr;

enum {
  kHeapExpandable = 2,
  kHeapNoExecute = 4,
  kHeapShared = 6,
  kHeapReadOnly = 8,
  kHeapNoFlags = 0
};

class Heap final {
 private:
  explicit Heap();

 public:
  ~Heap();

 public:
  HCORE_COPY_DEFAULT(Heap);

 public:
  static Heap *Shared() noexcept;

 public:
  void Delete(HeapPtr me) noexcept;
  SizeT Size(HeapPtr me) noexcept;
  HeapPtr New(const SizeT &sz, const Int32 flags = kHeapNoFlags);
};

class MemoryException final {
 public:
  explicit MemoryException() = default;
  ~MemoryException() = default;

 public:
  HCORE_COPY_DEFAULT(MemoryException);

 public:
  const char *Name();
  const char *Reason();

 private:
  const char *mReason{"HeapAPI: Memory Exception!"};

 private:
  friend Heap;
};
} // namespace System