@@ -150,6 +150,26 @@ TEST_P(umfPoolTest, allocFreeNonAlignedSizes) {
150
150
}
151
151
}
152
152
153
+ TEST_P (umfPoolTest, allocFreeAligned) {
154
+ #ifdef _WIN32
155
+ // TODO: implement support for windows
156
+ GTEST_SKIP ();
157
+ #else
158
+ if (!umf_test::isAlignedAllocSupported (pool.get ())) {
159
+ GTEST_SKIP ();
160
+ }
161
+
162
+ size_t alignment = 2097152 ;
163
+ void *ptr = umfPoolAlignedMalloc (pool.get (), 1 , alignment);
164
+ ASSERT_NE (ptr, nullptr );
165
+ ASSERT_TRUE (reinterpret_cast <uintptr_t >(ptr) % alignment == 0 );
166
+ *(reinterpret_cast <unsigned char *>(ptr)) = (unsigned char )0xFF ;
167
+
168
+ umf_result_t umf_result = umfPoolFree (pool.get (), ptr);
169
+ ASSERT_EQ (umf_result, UMF_RESULT_SUCCESS);
170
+ #endif
171
+ }
172
+
153
173
TEST_P (umfPoolTest, reallocFree) {
154
174
if (!umf_test::isReallocSupported (pool.get ())) {
155
175
GTEST_SKIP ();
@@ -203,6 +223,24 @@ void pow2AlignedAllocHelper(umf_memory_pool_handle_t pool) {
203
223
ASSERT_EQ (umf_result, UMF_RESULT_SUCCESS);
204
224
}
205
225
}
226
+
227
+ // the same for size = 1
228
+ for (size_t alignment = 1 ; alignment <= maxAlignment; alignment <<= 1 ) {
229
+ std::vector<void *> allocs;
230
+
231
+ for (size_t alloc = 0 ; alloc < numAllocs; alloc++) {
232
+ auto *ptr = umfPoolAlignedMalloc (pool, 1 , alignment);
233
+ ASSERT_NE (ptr, nullptr );
234
+ ASSERT_TRUE (reinterpret_cast <uintptr_t >(ptr) % alignment == 0 );
235
+ *(reinterpret_cast <unsigned char *>(ptr)) = (unsigned char )0xFF ;
236
+ allocs.push_back (ptr);
237
+ }
238
+
239
+ for (auto &ptr : allocs) {
240
+ umf_result_t umf_result = umfPoolFree (pool, ptr);
241
+ ASSERT_EQ (umf_result, UMF_RESULT_SUCCESS);
242
+ }
243
+ }
206
244
}
207
245
208
246
TEST_P (umfPoolTest, pow2AlignedAlloc) {
0 commit comments