MCPcopy Create free account
hub / github.com/Bareflank/hypervisor / platform_alloc

Function platform_alloc

loader/linux/src/platform.c:89–106  ·  view source on GitHub ↗

* <!-- description --> * @brief This function allocates read/write virtual memory from the * kernel. This memory is not physically contiguous. The resulting * pointer is at least 4k aligned, so use this function sparingly * as it will always allocate at least one page. Use platform_free() * to release this memory. * * @note This function must zero the allocated memory *

Source from the content-addressed store, hash-verified

87 * Returns a nullptr on failure.
88 */
89NODISCARD void *
90platform_alloc(uint64_t const size) NOEXCEPT
91{
92 void *mut_ret;
93
94 if (0 == size) {
95 bferror("invalid number of bytes (i.e., size)");
96 return NULLPTR;
97 }
98
99 mut_ret = vmalloc(size);
100 if (NULLPTR == mut_ret) {
101 bferror("vmalloc failed");
102 return NULLPTR;
103 }
104
105 return memset(mut_ret, 0, size);
106}
107
108/**
109 * <!-- description -->

Callers 1

dispatch_dump_vmmFunction · 0.70

Calls 1

bferrorFunction · 0.50

Tested by

no test coverage detected