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

Function attempt_alloc

Libs/sol/sol.hpp:10005–10022  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

10003 }
10004
10005 inline bool attempt_alloc(lua_State* L, std::size_t ptr_align, std::size_t ptr_size, std::size_t value_align, std::size_t value_size,
10006 std::size_t allocated_size, void*& pointer_adjusted, void*& data_adjusted) {
10007 void* adjusted = lua_newuserdata(L, allocated_size);
10008 pointer_adjusted = align(ptr_align, ptr_size, adjusted, allocated_size);
10009 if (pointer_adjusted == nullptr) {
10010 lua_pop(L, 1);
10011 return false;
10012 }
10013 // subtract size of what we're going to allocate there
10014 allocated_size -= ptr_size;
10015 adjusted = static_cast<void*>(static_cast<char*>(pointer_adjusted) + ptr_size);
10016 data_adjusted = align(value_align, value_size, adjusted, allocated_size);
10017 if (data_adjusted == nullptr) {
10018 lua_pop(L, 1);
10019 return false;
10020 }
10021 return true;
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) {

Callers 1

usertype_allocateFunction · 0.85

Calls 1

alignFunction · 0.85

Tested by

no test coverage detected