mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-05 19:11:50 +00:00
make StructLayout serializable
This commit is contained in:
parent
8447cf5ad5
commit
f5d2a1f1b7
5 changed files with 134 additions and 8 deletions
|
|
@ -3,6 +3,7 @@
|
|||
#include <cstdint>
|
||||
#include <cstring>
|
||||
#include <vector>
|
||||
#include <limits>
|
||||
#include <stdexcept>
|
||||
|
||||
namespace util {
|
||||
|
|
@ -62,9 +63,15 @@ namespace util {
|
|||
/// @param size entry size
|
||||
/// @return temporary entry pointer
|
||||
/// @attention pointer becomes invalid after allocate(...) or free(...)
|
||||
uint8_t* allocate(Tindex index, Tsize size) {
|
||||
uint8_t* allocate(Tindex index, size_t size) {
|
||||
const auto maxSize = std::numeric_limits<Tsize>::max();
|
||||
if (size > maxSize) {
|
||||
throw std::invalid_argument(
|
||||
"requested "+std::to_string(size)+" bytes but limit is "+
|
||||
std::to_string(maxSize));
|
||||
}
|
||||
if (size == 0) {
|
||||
throw std::runtime_error("size is 0");
|
||||
throw std::invalid_argument("zero size");
|
||||
}
|
||||
ptrdiff_t offset = 0;
|
||||
if (auto found = find(index)) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue