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

Function attempt_alloc

extlibs/sol3/include/sol/sol.hpp:9443–9460  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9441 }
9442
9443 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,
9444 std::size_t allocated_size, void*& pointer_adjusted, void*& data_adjusted) {
9445 void* adjusted = lua_newuserdata(L, allocated_size);
9446 pointer_adjusted = align(ptr_align, ptr_size, adjusted, allocated_size);
9447 if (pointer_adjusted == nullptr) {
9448 lua_pop(L, 1);
9449 return false;
9450 }
9451 // subtract size of what we're going to allocate there
9452 allocated_size -= ptr_size;
9453 adjusted = static_cast<void*>(static_cast<char*>(pointer_adjusted) + ptr_size);
9454 data_adjusted = align(value_align, value_size, adjusted, allocated_size);
9455 if (data_adjusted == nullptr) {
9456 lua_pop(L, 1);
9457 return false;
9458 }
9459 return true;
9460 }
9461
9462 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,
9463 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