aboutsummaryrefslogtreecommitdiff
path: root/src/linda.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/linda.cpp')
-rw-r--r--src/linda.cpp18
1 files changed, 5 insertions, 13 deletions
diff --git a/src/linda.cpp b/src/linda.cpp
index f2e39a8..eb2349e 100644
--- a/src/linda.cpp
+++ b/src/linda.cpp
@@ -759,7 +759,6 @@ static void* linda_id( lua_State* L, DeepOp op_)
759 { 759 {
760 case eDO_new: 760 case eDO_new:
761 { 761 {
762 struct s_Linda* s;
763 size_t name_len = 0; 762 size_t name_len = 0;
764 char const* linda_name = nullptr; 763 char const* linda_name = nullptr;
765 unsigned long linda_group = 0; 764 unsigned long linda_group = 0;
@@ -791,12 +790,9 @@ static void* linda_id( lua_State* L, DeepOp op_)
791 * One can use any memory allocation scheme. 790 * One can use any memory allocation scheme.
792 * just don't use L's allocF because we don't know which state will get the honor of GCing the linda 791 * just don't use L's allocF because we don't know which state will get the honor of GCing the linda
793 */ 792 */
794 Universe* const U = universe_get(L); 793 Universe* const U{ universe_get(L) };
795 { 794 struct s_Linda* s{ static_cast<struct s_Linda*>(U->internal_allocator.alloc(sizeof(struct s_Linda) + name_len)) }; // terminating 0 is already included
796 AllocatorDefinition* const allocD = &U->internal_allocator; 795 if (s)
797 s = (struct s_Linda*) allocD->allocF(allocD->allocUD, nullptr, 0, sizeof(struct s_Linda) + name_len); // terminating 0 is already included
798 }
799 if( s)
800 { 796 {
801 s->prelude.DeepPrelude::DeepPrelude(); 797 s->prelude.DeepPrelude::DeepPrelude();
802 SIGNAL_INIT( &s->read_happened); 798 SIGNAL_INIT( &s->read_happened);
@@ -812,12 +808,11 @@ static void* linda_id( lua_State* L, DeepOp op_)
812 808
813 case eDO_delete: 809 case eDO_delete:
814 { 810 {
815 Keeper* K;
816 struct s_Linda* linda = (struct s_Linda*) lua_touserdata( L, 1); 811 struct s_Linda* linda = (struct s_Linda*) lua_touserdata( L, 1);
817 ASSERT_L( linda); 812 ASSERT_L( linda);
818 813
819 // Clean associated structures in the keeper state. 814 // Clean associated structures in the keeper state.
820 K = keeper_acquire( linda->U->keepers, LINDA_KEEPER_HASHSEED( linda)); 815 Keeper* const K{ keeper_acquire(linda->U->keepers, LINDA_KEEPER_HASHSEED(linda)) };
821 if( K && K->L) // can be nullptr if this happens during main state shutdown (lanes is GC'ed -> no keepers -> no need to cleanup) 816 if( K && K->L) // can be nullptr if this happens during main state shutdown (lanes is GC'ed -> no keepers -> no need to cleanup)
822 { 817 {
823 // hopefully this won't ever raise an error as we would jump to the closest pcall site while forgetting to release the keeper mutex... 818 // hopefully this won't ever raise an error as we would jump to the closest pcall site while forgetting to release the keeper mutex...
@@ -829,10 +824,7 @@ static void* linda_id( lua_State* L, DeepOp op_)
829 SIGNAL_FREE( &linda->read_happened); 824 SIGNAL_FREE( &linda->read_happened);
830 SIGNAL_FREE( &linda->write_happened); 825 SIGNAL_FREE( &linda->write_happened);
831 linda->prelude.DeepPrelude::~DeepPrelude(); 826 linda->prelude.DeepPrelude::~DeepPrelude();
832 { 827 linda->U->internal_allocator.free(linda, sizeof(struct s_Linda) + strlen(linda->name));
833 AllocatorDefinition* const allocD = &linda->U->internal_allocator;
834 (void) allocD->allocF(allocD->allocUD, linda, sizeof(struct s_Linda) + strlen(linda->name), 0);
835 }
836 return nullptr; 828 return nullptr;
837 } 829 }
838 830