diff options
Diffstat (limited to 'src/linda.c')
-rw-r--r-- | src/linda.c | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/src/linda.c b/src/linda.c index 21b38fe..4149e71 100644 --- a/src/linda.c +++ b/src/linda.c | |||
@@ -758,9 +758,6 @@ LUAG_FUNC( linda_towatch) | |||
758 | */ | 758 | */ |
759 | static void* linda_id( lua_State* L, DeepOp op_) | 759 | static void* linda_id( lua_State* L, DeepOp op_) |
760 | { | 760 | { |
761 | Universe* const U = universe_get(L); | ||
762 | AllocatorDefinition* const allocD = &U->protected_allocator.definition; | ||
763 | |||
764 | switch( op_) | 761 | switch( op_) |
765 | { | 762 | { |
766 | case eDO_new: | 763 | case eDO_new: |
@@ -797,7 +794,17 @@ static void* linda_id( lua_State* L, DeepOp op_) | |||
797 | * One can use any memory allocation scheme. | 794 | * One can use any memory allocation scheme. |
798 | * just don't use L's allocF because we don't know which state will get the honor of GCing the linda | 795 | * just don't use L's allocF because we don't know which state will get the honor of GCing the linda |
799 | */ | 796 | */ |
800 | s = (struct s_Linda*) allocD->allocF( allocD->allocUD, NULL, 0, sizeof(struct s_Linda) + name_len); // terminating 0 is already included | 797 | // don't hijack the state allocator when running LuaJIT because it looks like LuaJIT does not expect it and might invalidate the memory unexpectedly |
798 | #if LUAJIT_FLAVOR == 0 | ||
799 | { | ||
800 | Universe* const U = universe_get(L); | ||
801 | AllocatorDefinition* const allocD = &U->protected_allocator.definition; | ||
802 | |||
803 | s = (struct s_Linda*)allocD->allocF(allocD->allocUD, NULL, 0, sizeof(struct s_Linda) + name_len); // terminating 0 is already included | ||
804 | } | ||
805 | #else // LUAJIT_FLAVOR | ||
806 | s = (struct s_Linda*)malloc(sizeof(struct s_Linda) + name_len); // terminating 0 is already included | ||
807 | #endif // LUAJIT_FLAVOR | ||
801 | if( s) | 808 | if( s) |
802 | { | 809 | { |
803 | s->prelude.magic.value = DEEP_VERSION.value; | 810 | s->prelude.magic.value = DEEP_VERSION.value; |
@@ -830,7 +837,17 @@ static void* linda_id( lua_State* L, DeepOp op_) | |||
830 | // There aren't any lanes waiting on these lindas, since all proxies have been gc'ed. Right? | 837 | // There aren't any lanes waiting on these lindas, since all proxies have been gc'ed. Right? |
831 | SIGNAL_FREE( &linda->read_happened); | 838 | SIGNAL_FREE( &linda->read_happened); |
832 | SIGNAL_FREE( &linda->write_happened); | 839 | SIGNAL_FREE( &linda->write_happened); |
833 | allocD->allocF( allocD->allocUD, linda, sizeof(struct s_Linda) + strlen(linda->name), 0); | 840 | // don't hijack the state allocator when running LuaJIT because it looks like LuaJIT does not expect it and might invalidate the memory unexpectedly |
841 | #if LUAJIT_FLAVOR == 0 | ||
842 | { | ||
843 | Universe* const U = universe_get(L); | ||
844 | AllocatorDefinition* const allocD = &U->protected_allocator.definition; | ||
845 | |||
846 | allocD->allocF(allocD->allocUD, linda, sizeof(struct s_Linda) + strlen(linda->name), 0); | ||
847 | } | ||
848 | #else // LUAJIT_FLAVOR | ||
849 | free(linda); | ||
850 | #endif // LUAJIT_FLAVOR | ||
834 | return NULL; | 851 | return NULL; |
835 | } | 852 | } |
836 | 853 | ||