MCPcopy Create free account
hub / github.com/ObEngine/ObEngine / align

Function align

extlibs/sol3/include/sol/sol.hpp:9271–9286  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9269 using unique_tag = detail::inheritance_unique_cast_function;
9270
9271 inline void* align(std::size_t alignment, std::size_t size, void*& ptr, std::size_t& space, std::size_t& required_space) {
9272 // this handels arbitrary alignments...
9273 // make this into a power-of-2-only?
9274 // actually can't: this is a C++14-compatible framework,
9275 // power of 2 alignment is C++17
9276 std::uintptr_t initial = reinterpret_cast<std::uintptr_t>(ptr);
9277 std::uintptr_t offby = static_cast<std::uintptr_t>(initial % alignment);
9278 std::uintptr_t padding = (alignment - offby) % alignment;
9279 required_space += size + padding;
9280 if (space < required_space) {
9281 return nullptr;
9282 }
9283 ptr = static_cast<void*>(static_cast<char*>(ptr) + padding);
9284 space -= padding;
9285 return ptr;
9286 }
9287
9288 inline void* align(std::size_t alignment, std::size_t size, void*& ptr, std::size_t& space) {
9289 std::size_t required_space = 0;

Callers 10

align_oneFunction · 0.85
align_usertype_pointerFunction · 0.85
align_usertype_uniqueFunction · 0.85
align_userFunction · 0.85
attempt_allocFunction · 0.85
attempt_alloc_uniqueFunction · 0.85
user_allocateFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected