aboutsummaryrefslogtreecommitdiff
path: root/src/universe.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/universe.cpp')
-rw-r--r--src/universe.cpp9
1 files changed, 3 insertions, 6 deletions
diff --git a/src/universe.cpp b/src/universe.cpp
index 357aa08..283747f 100644
--- a/src/universe.cpp
+++ b/src/universe.cpp
@@ -263,7 +263,7 @@ void Universe::initializeAllocatorFunction(lua_State* const L_)
263 LUA_ASSERT(L_, lua_isstring(L_, kIdxTop)); // should be the case due to lanes.lua parameter validation 263 LUA_ASSERT(L_, lua_isstring(L_, kIdxTop)); // should be the case due to lanes.lua parameter validation
264 std::string_view const _allocator{ luaG_tostring(L_, kIdxTop) }; 264 std::string_view const _allocator{ luaG_tostring(L_, kIdxTop) };
265 if (_allocator == "libc") { 265 if (_allocator == "libc") {
266 internalAllocator = lanes::AllocatorDefinition{ lanes::AllocatorDefinition::kAllocatorVersion, libc_lua_Alloc, nullptr }; 266 internalAllocator = lanes::AllocatorDefinition{ libc_lua_Alloc, nullptr };
267 } else { 267 } else {
268 // use whatever the provider provides 268 // use whatever the provider provides
269 internalAllocator = resolveAllocator(L_, "internal"); 269 internalAllocator = resolveAllocator(L_, "internal");
@@ -338,11 +338,8 @@ lanes::AllocatorDefinition Universe::resolveAllocator(lua_State* const L_, std::
338 lua_pushcclosure(L_, provideAllocator, 0); // L_: provideAllocator() 338 lua_pushcclosure(L_, provideAllocator, 0); // L_: provideAllocator()
339 luaG_pushstring(L_, hint_); // L_: provideAllocator() "<hint>" 339 luaG_pushstring(L_, hint_); // L_: provideAllocator() "<hint>"
340 lua_call(L_, 1, 1); // L_: result 340 lua_call(L_, 1, 1); // L_: result
341 lanes::AllocatorDefinition* const _def{ luaG_tofulluserdata<lanes::AllocatorDefinition>(L_, kIdxTop) }; 341 // make sure we have a valid AllocatorDefinition on the stack (an error is raised instead if it is not the case)
342 if (!_def || _def->version != lanes::AllocatorDefinition::kAllocatorVersion) { 342 _ret = lanes::AllocatorDefinition::Validated(L_, kIdxTop);
343 raise_luaL_error(L_, "Bad config.allocator function, must provide a valid AllocatorDefinition");
344 }
345 _ret = *_def;
346 lua_pop(L_, 1); // L_: 343 lua_pop(L_, 1); // L_:
347 STACK_CHECK(L_, 0); 344 STACK_CHECK(L_, 0);
348 return _ret; 345 return _ret;