sandbox
Loading...
Searching...
No Matches
blob.hpp
1// SPDX-License-Identifier: MIT
2#ifndef LIBSBX_MEMORY_BLOB_HPP_
3#define LIBSBX_MEMORY_BLOB_HPP_
4
5#include <memory>
6
7namespace sbx::memory {
8
9using blob = std::shared_ptr<std::uint8_t[]>;
10
11inline auto make_blob(const std::uint8_t* data, const std::size_t size) -> blob {
12 auto blob = std::make_shared<std::uint8_t[]>(size);
13
14 if (data != nullptr && size > 0u) {
15 std::memcpy(blob.get(), data, size);
16 }
17
18 return blob;
19}
20
21
22} // namespace sbx::memory
23
24#endif // LIBSBX_MEMORY_BLOB_HPP_