maybe stack fixed?
parent
7810a21226
commit
06078fddc4
|
@ -1,5 +1,5 @@
|
||||||
cmake_minimum_required(VERSION 3.25)
|
cmake_minimum_required(VERSION 3.25)
|
||||||
project(blt-gp VERSION 0.0.96)
|
project(blt-gp VERSION 0.0.97)
|
||||||
|
|
||||||
include(CTest)
|
include(CTest)
|
||||||
|
|
||||||
|
|
|
@ -117,6 +117,8 @@ namespace blt::gp
|
||||||
reinterpret_cast<NO_REF_T*>(head->metadata.offset - TYPE_SIZE)->~NO_REF_T();
|
reinterpret_cast<NO_REF_T*>(head->metadata.offset - TYPE_SIZE)->~NO_REF_T();
|
||||||
// move offset back
|
// move offset back
|
||||||
head->metadata.offset -= TYPE_SIZE;
|
head->metadata.offset -= TYPE_SIZE;
|
||||||
|
// moving back allows us to allocate with other data, if there is room.
|
||||||
|
while (head->used_bytes_in_block() == 0 && move_back());
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -189,6 +191,7 @@ namespace blt::gp
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
while (head->used_bytes_in_block() == 0 && move_back());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -212,6 +215,7 @@ namespace blt::gp
|
||||||
to.head->metadata.offset = static_cast<blt::u8*>(ptr) + type_size;
|
to.head->metadata.offset = static_cast<blt::u8*>(ptr) + type_size;
|
||||||
std::memcpy(ptr, head->metadata.offset - type_size, type_size);
|
std::memcpy(ptr, head->metadata.offset - type_size, type_size);
|
||||||
head->metadata.offset -= type_size;
|
head->metadata.offset -= type_size;
|
||||||
|
while (head->used_bytes_in_block() == 0 && move_back());
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename... Args>
|
template<typename... Args>
|
||||||
|
|
|
@ -52,9 +52,9 @@ large_##SIZE tertiary_##SIZE = make_data(large_##SIZE{}, [](auto index) {
|
||||||
return static_cast<blt::u8>(blt::random::murmur_random64c<blt::size_t>(SEED + index, 0, 256)); \
|
return static_cast<blt::u8>(blt::random::murmur_random64c<blt::size_t>(SEED + index, 0, 256)); \
|
||||||
})
|
})
|
||||||
|
|
||||||
#define RUN_TEST(FAILURE_COND, PASS, ...) do { if (FAILURE_COND) { BLT_ERROR(__VA_ARGS__); } else { BLT_DEBUG(PASS); } } while(false)
|
#define RUN_TEST(FAILURE_COND, STACK, PASS, ...) do { if (FAILURE_COND) { BLT_ERROR(__VA_ARGS__); } else { BLT_DEBUG_STREAM << PASS << " | " << STACK.size() << "\n"; } } while(false)
|
||||||
#define RUN_TEST_SIZE(VALUE, SIZE, STACK) RUN_TEST(auto index = compare(VALUE, STACK.pop<SIZE>()); index >= 0, #SIZE " Test PASSED.", "Failed to pop large value (" #SIZE "), failed at index %ld", index)
|
#define RUN_TEST_SIZE(VALUE, SIZE, STACK) RUN_TEST(auto index = compare(VALUE, STACK.pop<SIZE>()); index >= 0, STACK, #SIZE " test PASSED.", "Failed to pop large value (" #SIZE "), failed at index %ld", index)
|
||||||
#define RUN_TEST_TYPE(TYPE, EXPECTED, STACK) RUN_TEST(auto val = STACK.pop<TYPE>(); val != EXPECTED, #TYPE " test PASSED", "Failed to pop correct " #TYPE " (" #EXPECTED ") found %lf", val);
|
#define RUN_TEST_TYPE(TYPE, EXPECTED, STACK) RUN_TEST(auto val = STACK.pop<TYPE>(); val != EXPECTED, STACK, #TYPE " test PASSED", "Failed to pop correct " #TYPE " (" #EXPECTED ") found %lf", val);
|
||||||
|
|
||||||
const blt::u64 SEED = std::random_device()();
|
const blt::u64 SEED = std::random_device()();
|
||||||
|
|
||||||
|
@ -189,14 +189,13 @@ void test_basic_types()
|
||||||
BLT_TRACE_STREAM << stack.size() << "\n";
|
BLT_TRACE_STREAM << stack.size() << "\n";
|
||||||
std::cout << std::endl;
|
std::cout << std::endl;
|
||||||
|
|
||||||
BLT_INFO("Some fishy numbers in the last reported size. Let's try modifying the stack.");
|
BLT_INFO("Some fishy numbers in the last reported size. Let's try modifying the stack."); // fixed by moving back in pop
|
||||||
stack.push(88.9f);
|
stack.push(88.9f);
|
||||||
BLT_TRACE_STREAM << "Pushed float: " << stack.size() << "\n";
|
BLT_TRACE_STREAM << "Pushed float: " << stack.size() << "\n";
|
||||||
|
|
||||||
{
|
{
|
||||||
BLT_INFO("Popping a few values.");
|
BLT_INFO("Popping a few values.");
|
||||||
RUN_TEST_TYPE(float, 88.9f, stack);
|
RUN_TEST_TYPE(float, 88.9f, stack);
|
||||||
BLT_TRACE_STREAM << "popped float: " << stack.size() << "\n";
|
|
||||||
RUN_TEST_SIZE(secondary_256, large_256, stack);
|
RUN_TEST_SIZE(secondary_256, large_256, stack);
|
||||||
}
|
}
|
||||||
BLT_TRACE_STREAM << stack.size() << "\n";
|
BLT_TRACE_STREAM << stack.size() << "\n";
|
||||||
|
|
Loading…
Reference in New Issue