Skip to content

Commit

Permalink
More fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Mr-Wiseguy committed Oct 17, 2024
1 parent 1510e4a commit fc64d0b
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions tests/test_general.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,16 @@ constexpr std::size_t KiB = 1024U;
constexpr std::size_t MiB = KiB * KiB;

#ifdef _WIN32
auto make_arena(size_t align, size_t size) -> std::shared_ptr<std::byte>
auto make_arena(std::align_val_t align, size_t size) -> std::shared_ptr<std::byte>
{
return std::shared_ptr<std::byte>(static_cast<std::byte*>(_aligned_malloc(size, align)),
&_aligned_free);
return std::shared_ptr<std::byte>(
static_cast<std::byte*>(_aligned_malloc(size, static_cast<size_t>(align))), &_aligned_free);
}
#else
auto make_arena(size_t align, size_t size) -> std::shared_ptr<std::byte>
auto make_arena(std::align_val_t align, size_t size) -> std::shared_ptr<std::byte>
{
return std::shared_ptr<std::byte>(static_cast<std::byte*>(std::aligned_alloc(align, size)),
&_aligned_free);
return std::shared_ptr<std::byte>(
static_cast<std::byte*>(std::aligned_alloc(static_cast<size_t>(align), size)), &_aligned_free);
}
#endif

Expand Down Expand Up @@ -151,7 +151,7 @@ TEST_CASE("General: allocate: OOM")
{
constexpr auto MiB256 = MiB * 256U;
constexpr auto ArenaSize = MiB256 + MiB;
const std::shared_ptr<std::byte> arena = make_arena(64U, ArenaSize);
const std::shared_ptr<std::byte> arena = make_arena(std::align_val_t(64U), ArenaSize);

auto heap = init(arena.get(), ArenaSize);
REQUIRE(heap != nullptr);
Expand Down Expand Up @@ -192,7 +192,7 @@ TEST_CASE("General: allocate: smallest")
using internal::Fragment;

constexpr auto ArenaSize = MiB * 300U;
const std::shared_ptr<std::byte> arena = make_arena(64U, ArenaSize);
const std::shared_ptr<std::byte> arena = make_arena(std::align_val_t(64U), ArenaSize);

auto heap = init(arena.get(), ArenaSize);
REQUIRE(heap != nullptr);
Expand Down Expand Up @@ -224,7 +224,7 @@ TEST_CASE("General: allocate: size_t overflow")
constexpr auto size_max = std::numeric_limits<uint32_t>::max();

constexpr auto ArenaSize = MiB * 300U;
const std::shared_ptr<std::byte> arena = make_arena(64U, ArenaSize);
const std::shared_ptr<std::byte> arena = make_arena(std::align_val_t(64U), ArenaSize);

auto heap = init(arena.get(), ArenaSize);
REQUIRE(heap != nullptr);
Expand Down Expand Up @@ -496,7 +496,7 @@ TEST_CASE("General: random A")
using internal::Fragment;

constexpr auto ArenaSize = MiB * 300U;
const std::shared_ptr<std::byte> arena = make_arena(64U, ArenaSize);
const std::shared_ptr<std::byte> arena = make_arena(std::align_val_t(64U), ArenaSize);
std::generate_n(arena.get(), ArenaSize, getRandomByte); // Random-fill the ENTIRE arena!
auto heap = init(arena.get(), ArenaSize);
REQUIRE(heap != nullptr);
Expand Down

0 comments on commit fc64d0b

Please sign in to comment.