Merge branch 'main' into fix-basic-parser-exponential-notation

This commit is contained in:
MihailRis 2026-07-07 17:50:10 +03:00
commit 98dfeb8da6
3 changed files with 11 additions and 4 deletions

View file

@ -11,9 +11,9 @@
namespace util {
template<typename T>
inline T read_int_le(const uint8_t* src, ptrdiff_t offset=0) {
inline T read_int_le(const uint8_t* src) {
T tmp;
std::memcpy(&tmp, src + offset * sizeof(T), sizeof(T));
std::memcpy(&tmp, src, sizeof(T));
return dataio::le2h(tmp);
}
@ -126,7 +126,7 @@ namespace util {
if (ptr == nullptr) {
return 0;
}
return read_int_le<Tsize>(ptr, -1);
return read_int_le<Tsize>(ptr - sizeof(Tsize));
}
/// @return number of entries
@ -177,7 +177,7 @@ namespace util {
) : buffer(buffer), index(index), offset(offset) {}
Tsize size() const {
return read_int_le<Tsize>(buffer.data() + offset, -1);
return read_int_le<Tsize>(buffer.data() + offset - sizeof(Tsize));
}
bool operator!=(const const_iterator& o) const {

View file

@ -33,6 +33,7 @@ static void init_gl_extensions_list() {
}
}
[[maybe_unused]]
static bool is_gl_extension_supported(const char *extension) {
if (!extension || !*extension) {
return false;
@ -40,6 +41,7 @@ static bool is_gl_extension_supported(const char *extension) {
return supported_gl_extensions.find(extension) != supported_gl_extensions.end();
}
#ifndef __APPLE__
static const char* gl_error_name(int error) {
switch (error) {
case GL_DEBUG_TYPE_ERROR: return "ERROR";
@ -80,6 +82,7 @@ static void GLAPIENTRY gl_message_callback(
logger.warning() << "GL:" << gl_error_name(type) << ":"
<< gl_severity_name(severity) << ": " << message;
}
#endif
static bool initialize_gl(int width, int height) {
glewExperimental = GL_TRUE;

View file

@ -8,9 +8,13 @@ TEST(SmallHeap, Allocation) {
auto index = 0;
auto size = 4;
std::cout << "step 1" << std::endl;
SmallHeap<uint16_t, uint8_t> map;
std::cout << "step 2" << std::endl;
auto ptr = map.allocate(index, size);
std::cout << "ptr: " << (void*)ptr << " le2h(1): " << dataio::le2h(1) << " h2le(1): " << dataio::h2le(1) << std::endl;
EXPECT_EQ(map.sizeOf(ptr), size);
std::cout << "step 4" << std::endl;
EXPECT_EQ(ptr, map.find(index));
}