Skip to content

Commit b5a0ed9

Browse files
authored
Merge pull request #100 from ldorau/Malloc_should_return_address_aligned_to_8_bytes
Malloc should return address aligned to 8 bytes
2 parents 51e72c4 + 7dd2304 commit b5a0ed9

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

test/malloc_compliance_tests.cpp

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
#include "base.hpp"
1919
using umf_test::test;
2020

21+
#define ALLOC_MIN_ALIGNMENT 8
22+
2123
//------------------------------------------------------------------------
2224
// Configurable defs
2325
//------------------------------------------------------------------------
@@ -57,15 +59,9 @@ void malloc_compliance_test(umf_memory_pool_handle_t hPool) {
5759
alloc_ptr_size[i] = rand_alloc_size(MAX_ALLOC_SIZE);
5860
alloc_ptr[i] = umfPoolMalloc(hPool, alloc_ptr_size[i]);
5961

60-
#ifndef _WIN32 // TODO: explain why it fails on some Windows systems
61-
// Supported under USE_WEAK_ALIGNMENT_RULES macro
62-
// For compatibility, on 64-bit systems malloc should align to 16 bytes
63-
size_t alignment =
64-
(sizeof(intptr_t) > 4 && alloc_ptr_size[i] > 8) ? 16 : 8;
65-
ASSERT_NE(addressIsAligned(alloc_ptr[i], alignment), 0)
62+
ASSERT_NE(addressIsAligned(alloc_ptr[i], ALLOC_MIN_ALIGNMENT), 0)
6663
<< "Malloc should return pointer that is suitably aligned so that "
6764
"it may be assigned to a pointer to any type of object";
68-
#endif
6965

7066
// Fill memory with a pattern ((id of the allocation) % 256)
7167
ASSERT_NE(alloc_ptr[i], nullptr)

0 commit comments

Comments
 (0)