summaryrefslogtreecommitdiffhomepage
path: root/Public/Kits/SystemKit/HeapAPI.hxx
blob: e9bda42d57d2167ce8f2dc9dd1a5bfa0b5f14c96 (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
/*
 *	========================================================
 *
 *	h-core
 * 	Copyright Mahrouss Logic, all rights reserved.
 *
 * 	========================================================
 */

#pragma once

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

using namespace HCore;

class HMemoryException;

typedef VoidPtr HHeapPtr;

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

class HHeap final {
 private:
  explicit HHeap();

 public:
  ~HHeap();

 public:
  HCORE_COPY_DEFAULT(HHeap);

 public:
  static HHeap *Shared() noexcept;

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

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

 public:
  HCORE_COPY_DEFAULT(HMemoryException);

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

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

 private:
  friend HHeap;
};