mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-10 13:31:49 +00:00
Merge branch 'main' into fix-basic-parser-exponential-notation
This commit is contained in:
commit
f7219d97d8
1 changed files with 12 additions and 7 deletions
|
|
@ -11,8 +11,10 @@
|
||||||
|
|
||||||
namespace util {
|
namespace util {
|
||||||
template<typename T>
|
template<typename T>
|
||||||
inline T read_int_le(const uint8_t* src, size_t offset=0) {
|
inline T read_int_le(const uint8_t* src, ptrdiff_t offset=0) {
|
||||||
return dataio::le2h(*(reinterpret_cast<const T*>(src) + offset));
|
T tmp;
|
||||||
|
std::memcpy(&tmp, src + offset * sizeof(T), sizeof(T));
|
||||||
|
return dataio::le2h(tmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @brief Simple heap implementation for memory-optimal sparse array of
|
/// @brief Simple heap implementation for memory-optimal sparse array of
|
||||||
|
|
@ -87,8 +89,7 @@ namespace util {
|
||||||
std::memset(found, 0, entrySize);
|
std::memset(found, 0, entrySize);
|
||||||
return found;
|
return found;
|
||||||
}
|
}
|
||||||
this->free(found);
|
free(found);
|
||||||
return allocate(index, size);
|
|
||||||
}
|
}
|
||||||
for (size_t i = 0; i < entriesCount; i++) {
|
for (size_t i = 0; i < entriesCount; i++) {
|
||||||
auto data = buffer.data() + offset;
|
auto data = buffer.data() + offset;
|
||||||
|
|
@ -110,9 +111,12 @@ namespace util {
|
||||||
entriesCount++;
|
entriesCount++;
|
||||||
|
|
||||||
auto data = buffer.data() + offset;
|
auto data = buffer.data() + offset;
|
||||||
*reinterpret_cast<Tindex*>(data) = dataio::h2le(index);
|
|
||||||
|
Tindex indexTmp = dataio::h2le(index);
|
||||||
|
Tsize sizeTmp = dataio::h2le(size);
|
||||||
|
std::memcpy(data, &indexTmp, sizeof(Tindex));
|
||||||
data += sizeof(Tindex);
|
data += sizeof(Tindex);
|
||||||
*reinterpret_cast<Tsize*>(data) = dataio::h2le(size);
|
std::memcpy(data, &sizeTmp, sizeof(Tsize));
|
||||||
return data + sizeof(Tsize);
|
return data + sizeof(Tsize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -147,7 +151,8 @@ namespace util {
|
||||||
ubyte* dst = out.data();
|
ubyte* dst = out.data();
|
||||||
const ubyte* src = buffer.data();
|
const ubyte* src = buffer.data();
|
||||||
|
|
||||||
*reinterpret_cast<Tindex*>(dst) = dataio::h2le(entriesCount);
|
Tindex countTmp = dataio::h2le(entriesCount);
|
||||||
|
std::memcpy(dst, &countTmp, sizeof(Tindex));
|
||||||
dst += sizeof(Tindex);
|
dst += sizeof(Tindex);
|
||||||
|
|
||||||
std::memcpy(dst, src, buffer.size());
|
std::memcpy(dst, src, buffer.size());
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue