diff options
Diffstat (limited to 'src/lanes.cpp')
-rw-r--r-- | src/lanes.cpp | 20 |
1 files changed, 5 insertions, 15 deletions
diff --git a/src/lanes.cpp b/src/lanes.cpp index 99c5812..5945a1a 100644 --- a/src/lanes.cpp +++ b/src/lanes.cpp | |||
@@ -254,10 +254,7 @@ static void lane_cleanup( Lane* s) | |||
254 | } | 254 | } |
255 | #endif // HAVE_LANE_TRACKING() | 255 | #endif // HAVE_LANE_TRACKING() |
256 | 256 | ||
257 | { | 257 | s->U->internal_allocator.free(s, sizeof(Lane)); |
258 | AllocatorDefinition* const allocD = &s->U->internal_allocator; | ||
259 | (void) allocD->allocF(allocD->allocUD, s, sizeof(Lane), 0); | ||
260 | } | ||
261 | } | 258 | } |
262 | 259 | ||
263 | /* | 260 | /* |
@@ -584,7 +581,7 @@ static int selfdestruct_gc( lua_State* L) | |||
584 | close_keepers( U); | 581 | close_keepers( U); |
585 | 582 | ||
586 | // remove the protected allocator, if any | 583 | // remove the protected allocator, if any |
587 | cleanup_allocator_function( U, L); | 584 | U->protected_allocator.removeFrom(L); |
588 | 585 | ||
589 | U->Universe::~Universe(); | 586 | U->Universe::~Universe(); |
590 | 587 | ||
@@ -1036,10 +1033,6 @@ static constexpr UniqueKey GCCB_KEY{ 0xcfb1f046ef074e88ull }; | |||
1036 | // | 1033 | // |
1037 | LUAG_FUNC( lane_new) | 1034 | LUAG_FUNC( lane_new) |
1038 | { | 1035 | { |
1039 | lua_State* L2; | ||
1040 | Lane* s; | ||
1041 | Lane** ud; | ||
1042 | |||
1043 | char const* libs_str = lua_tostring( L, 2); | 1036 | char const* libs_str = lua_tostring( L, 2); |
1044 | bool const have_priority{ !lua_isnoneornil(L, 3) }; | 1037 | bool const have_priority{ !lua_isnoneornil(L, 3) }; |
1045 | int const priority = have_priority ? (int) lua_tointeger( L, 3) : THREAD_PRIO_DEFAULT; | 1038 | int const priority = have_priority ? (int) lua_tointeger( L, 3) : THREAD_PRIO_DEFAULT; |
@@ -1066,7 +1059,7 @@ LUAG_FUNC( lane_new) | |||
1066 | DEBUGSPEW_CODE( ++ U->debugspew_indent_depth); | 1059 | DEBUGSPEW_CODE( ++ U->debugspew_indent_depth); |
1067 | 1060 | ||
1068 | // populate with selected libraries at the same time | 1061 | // populate with selected libraries at the same time |
1069 | L2 = luaG_newstate( U, L, libs_str); // L // L2 | 1062 | lua_State* const L2{ luaG_newstate(U, L, libs_str) }; // L // L2 |
1070 | 1063 | ||
1071 | STACK_GROW( L2, nargs + 3); // | 1064 | STACK_GROW( L2, nargs + 3); // |
1072 | STACK_CHECK_START_REL(L2, 0); | 1065 | STACK_CHECK_START_REL(L2, 0); |
@@ -1219,11 +1212,8 @@ LUAG_FUNC( lane_new) | |||
1219 | // 's' is allocated from heap, not Lua, since its life span may surpass the handle's (if free running thread) | 1212 | // 's' is allocated from heap, not Lua, since its life span may surpass the handle's (if free running thread) |
1220 | // | 1213 | // |
1221 | // a Lane full userdata needs a single uservalue | 1214 | // a Lane full userdata needs a single uservalue |
1222 | ud = (Lane**) lua_newuserdatauv( L, sizeof( Lane*), 1); // func libs priority globals package required gc_cb lane | 1215 | Lane** const ud{ static_cast<Lane**>(lua_newuserdatauv(L, sizeof(Lane*), 1)) }; // func libs priority globals package required gc_cb lane |
1223 | { | 1216 | Lane* const s{ *ud = static_cast<Lane*>(U->internal_allocator.alloc(sizeof(Lane))) }; // don't forget to store the pointer in the userdata! |
1224 | AllocatorDefinition* const allocD = &U->internal_allocator; | ||
1225 | s = *ud = (Lane*) allocD->allocF(allocD->allocUD, nullptr, 0, sizeof(Lane)); | ||
1226 | } | ||
1227 | if( s == nullptr) | 1217 | if( s == nullptr) |
1228 | { | 1218 | { |
1229 | return luaL_error( L, "could not create lane: out of memory"); | 1219 | return luaL_error( L, "could not create lane: out of memory"); |