MCPcopy Create free account
hub / github.com/TombEngine/TombEngine / attempt_alloc_unique

Function attempt_alloc_unique

Libs/sol/sol.hpp:10024–10058  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

10022 }
10023
10024 inline bool attempt_alloc_unique(lua_State* L, std::size_t ptr_align, std::size_t ptr_size, std::size_t real_align, std::size_t real_size,
10025 std::size_t allocated_size, void*& pointer_adjusted, void*& dx_adjusted, void*& id_adjusted, void*& data_adjusted) {
10026 void* adjusted = lua_newuserdata(L, allocated_size);
10027 pointer_adjusted = align(ptr_align, ptr_size, adjusted, allocated_size);
10028 if (pointer_adjusted == nullptr) {
10029 lua_pop(L, 1);
10030 return false;
10031 }
10032 allocated_size -= ptr_size;
10033
10034 adjusted = static_cast<void*>(static_cast<char*>(pointer_adjusted) + ptr_size);
10035 dx_adjusted = align(std::alignment_of_v<unique_destructor>, sizeof(unique_destructor), adjusted, allocated_size);
10036 if (dx_adjusted == nullptr) {
10037 lua_pop(L, 1);
10038 return false;
10039 }
10040 allocated_size -= sizeof(unique_destructor);
10041
10042 adjusted = static_cast<void*>(static_cast<char*>(dx_adjusted) + sizeof(unique_destructor));
10043
10044 id_adjusted = align(std::alignment_of_v<unique_tag>, sizeof(unique_tag), adjusted, allocated_size);
10045 if (id_adjusted == nullptr) {
10046 lua_pop(L, 1);
10047 return false;
10048 }
10049 allocated_size -= sizeof(unique_tag);
10050
10051 adjusted = static_cast<void*>(static_cast<char*>(id_adjusted) + sizeof(unique_tag));
10052 data_adjusted = align(real_align, real_size, adjusted, allocated_size);
10053 if (data_adjusted == nullptr) {
10054 lua_pop(L, 1);
10055 return false;
10056 }
10057 return true;
10058 }
10059
10060 template <typename T>
10061 T* usertype_allocate(lua_State* L) {

Callers 1

usertype_unique_allocateFunction · 0.85

Calls 1

alignFunction · 0.85

Tested by

no test coverage detected