MCPcopy Create free account
hub / github.com/apache/arrow / AllocateAligned

Method AllocateAligned

cpp/src/arrow/memory_pool.cc:298–330  ·  view source on GitHub ↗

Allocate memory according to the alignment requirements for Arrow (as of May 2016 64 bytes)

Source from the content-addressed store, hash-verified

296 // Allocate memory according to the alignment requirements for Arrow
297 // (as of May 2016 64 bytes)
298 static Status AllocateAligned(int64_t size, int64_t alignment, uint8_t** out) {
299 if (size == 0) {
300 *out = memory_pool::internal::kZeroSizeArea;
301 return Status::OK();
302 }
303#ifdef _WIN32
304 // Special code path for Windows
305 *out = reinterpret_cast<uint8_t*>(
306 _aligned_malloc(static_cast<size_t>(size), static_cast<size_t>(alignment)));
307 if (!*out) {
308 return Status::OutOfMemory("malloc of size ", size, " failed");
309 }
310#elif defined(sun) || defined(__sun)
311 *out = reinterpret_cast<uint8_t*>(
312 memalign(static_cast<size_t>(alignment), static_cast<size_t>(size)));
313 if (!*out) {
314 return Status::OutOfMemory("malloc of size ", size, " failed");
315 }
316#else
317 const int result =
318 posix_memalign(reinterpret_cast<void**>(out), static_cast<size_t>(alignment),
319 static_cast<size_t>(size));
320 if (result == ENOMEM) {
321 return Status::OutOfMemory("malloc of size ", size, " failed");
322 }
323
324 if (result == EINVAL) {
325 return Status::Invalid("invalid alignment parameter: ",
326 static_cast<size_t>(alignment));
327 }
328#endif
329 return Status::OK();
330 }
331
332 static Status ReallocateAligned(int64_t old_size, int64_t new_size, int64_t alignment,
333 uint8_t** ptr) {

Callers

nothing calls this directly

Calls 3

OutOfMemoryFunction · 0.85
OKFunction · 0.70
InvalidFunction · 0.70

Tested by

no test coverage detected