MCPcopy Create free account
hub / github.com/alibaba/yalantinglibs / aligned_malloc

Function aligned_malloc

include/ylt/util/concurrentqueue.h:4234–4247  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4232
4233 template <typename TAlign>
4234 static inline void* aligned_malloc(size_t size) {
4235 MOODYCAMEL_CONSTEXPR_IF(std::alignment_of<TAlign>::value <=
4236 std::alignment_of<details::max_align_t>::value)
4237 return (Traits::malloc)(size);
4238 else {
4239 size_t alignment = std::alignment_of<TAlign>::value;
4240 void* raw = (Traits::malloc)(size + alignment - 1 + sizeof(void*));
4241 if (!raw)
4242 return nullptr;
4243 char* ptr = details::align_for<TAlign>(reinterpret_cast<char*>(raw) +
4244 sizeof(void*));
4245 *(reinterpret_cast<void**>(ptr) - 1) = raw;
4246 return ptr;
4247 }
4248 }
4249
4250 template <typename TAlign>

Callers

nothing calls this directly

Calls 1

MOODYCAMEL_CONSTEXPR_IFFunction · 0.85

Tested by

no test coverage detected