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