* <!-- 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 *
| 87 | * Returns a nullptr on failure. |
| 88 | */ |
| 89 | NODISCARD void * |
| 90 | platform_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 --> |
no test coverage detected