blob: fa6bc146b63cb03f2ed5e81f75e346243cfd165e (
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
|
/* -------------------------------------------
Copyright (C) 2024-2025, Amlal EL Mahrouss, all rights reserved.
------------------------------------------- */
#include <BootKit/Platform.h>
#include <BootKit/Protocol.h>
#include <BootKit/BootKit.h>
#ifdef __BOOTZ_STANDALONE__
EXTERN EfiBootServices* BS;
/// @brief Allocates a new object.
/// @param sz the size.
/// @return
void* operator new(size_t sz)
{
void* buf = nullptr;
while (BS->AllocatePool(EfiMemoryType::EfiLoaderData, sz, &buf) != kEfiOk)
BS->FreePool(buf);
return buf;
}
/// @brief Allocates a new object.
/// @param sz the size.
/// @return
void* operator new[](size_t sz)
{
void* buf = nullptr;
BS->AllocatePool(EfiMemoryType::EfiLoaderData, sz, &buf);
return buf;
}
/// @brief Deletes the object.
/// @param buf the object.
void operator delete(void* buf)
{
BS->FreePool(buf);
}
/// @brief Deletes the object.
/// @param buf the object.
void operator delete[](void* buf)
{
BS->FreePool(buf);
}
/// @brief Deletes the object (array specific).
/// @param buf the object.
/// @param size it's size.
void operator delete(void* buf, size_t size)
{
BS->FreePool(buf);
}
#endif // __BOOTZ_STANDALONE__
|