From 0b6dfa6f87b551692fdc630e35e7bfa8c277e0dc Mon Sep 17 00:00:00 2001 From: Brett Laptop Date: Fri, 16 Feb 2024 20:06:17 -0500 Subject: [PATCH] person pointers --- libs/BLT | 2 +- src/lilfbtf.cpp | 2 ++ tests/src/main.cpp | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 35 insertions(+), 1 deletion(-) diff --git a/libs/BLT b/libs/BLT index 68f6a0a..8af1db4 160000 --- a/libs/BLT +++ b/libs/BLT @@ -1 +1 @@ -Subproject commit 68f6a0af44fe8ba5044a7f37b8bac9809ab709f1 +Subproject commit 8af1db43c3dd8a260729030365a4eabc8246ccf6 diff --git a/src/lilfbtf.cpp b/src/lilfbtf.cpp index 6c853e3..e98a799 100644 --- a/src/lilfbtf.cpp +++ b/src/lilfbtf.cpp @@ -17,6 +17,8 @@ */ #include +#include +#include namespace lilfb { diff --git a/tests/src/main.cpp b/tests/src/main.cpp index 4f9de56..74c9cef 100644 --- a/tests/src/main.cpp +++ b/tests/src/main.cpp @@ -1,7 +1,39 @@ #include +#include +#include +#include + +struct data { + float f; + int i; + char c; +}; int main() { + size_t size = 32; + size_t remaining_bytes = size; + size_t offset = 0; + void* void_ptr = nullptr; + char* new_ptr = nullptr; + char* buffer = new char[size]; + + remaining_bytes = size - offset; + std::cout << static_cast(buffer) << " ' " << remaining_bytes << std::endl; + void_ptr = reinterpret_cast(&buffer[offset]); + new_ptr = static_cast(std::align(alignof(char), sizeof(char), void_ptr, remaining_bytes)); + std::cout << static_cast(new_ptr) << " : " << remaining_bytes << " | " << (buffer - new_ptr + sizeof(char)) << std::endl; + offset += (buffer - new_ptr + sizeof(char)); + + remaining_bytes = size - offset; + void_ptr = reinterpret_cast(&buffer[offset]); + new_ptr = static_cast(std::align(alignof(data), sizeof(data), void_ptr, remaining_bytes)); + std::cout << static_cast(new_ptr) << " : " << remaining_bytes << " | " << (buffer - new_ptr + sizeof(data)) << std::endl; + offset += (buffer - new_ptr + sizeof(data)); + + + delete[](buffer); + std::cout << "Hello, World!" << std::endl; return 0; }