aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGES3
-rw-r--r--src/keeper.c4
-rw-r--r--src/lanes.c28
3 files changed, 19 insertions, 16 deletions
diff --git a/CHANGES b/CHANGES
index 0352c9e..ed1daee 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,5 +1,8 @@
1CHANGES: 1CHANGES:
2 2
3CHANGE 106: BGe 17-Mar-14
4 * Fixed crash when using protect_allocator option
5
3CHANGE 105: BGe 27-Feb-14 6CHANGE 105: BGe 27-Feb-14
4 * Bumped version to 3.9.3 7 * Bumped version to 3.9.3
5 * new exposed variable linda.null that exposes the internal NIL_SENTINEL marker 8 * new exposed variable linda.null that exposes the internal NIL_SENTINEL marker
diff --git a/src/keeper.c b/src/keeper.c
index 7362ca6..4d2d068 100644
--- a/src/keeper.c
+++ b/src/keeper.c
@@ -612,7 +612,7 @@ void close_keepers( struct s_Universe* U, lua_State* L)
612 { 612 {
613 void* allocUD; 613 void* allocUD;
614 lua_Alloc allocF = lua_getallocf( L, &allocUD); 614 lua_Alloc allocF = lua_getallocf( L, &allocUD);
615 allocF( L, U->keepers, sizeof( struct s_Keepers) + (nbKeepers - 1) * sizeof(struct s_Keeper), 0); 615 allocF( allocUD, U->keepers, sizeof( struct s_Keepers) + (nbKeepers - 1) * sizeof(struct s_Keeper), 0);
616 U->keepers = NULL; 616 U->keepers = NULL;
617 } 617 }
618 } 618 }
@@ -645,7 +645,7 @@ void init_keepers( struct s_Universe* U, lua_State* L)
645 // struct s_Keepers contains an array of 1 s_Keeper, adjust for the actual number of keeper states 645 // struct s_Keepers contains an array of 1 s_Keeper, adjust for the actual number of keeper states
646 { 646 {
647 size_t const bytes = sizeof( struct s_Keepers) + (nb_keepers - 1) * sizeof(struct s_Keeper); 647 size_t const bytes = sizeof( struct s_Keepers) + (nb_keepers - 1) * sizeof(struct s_Keeper);
648 U->keepers = (struct s_Keepers*) allocF( L, NULL, 0, bytes); 648 U->keepers = (struct s_Keepers*) allocF( allocUD, NULL, 0, bytes);
649 if( U->keepers == NULL) 649 if( U->keepers == NULL)
650 { 650 {
651 (void) luaL_error( L, "init_keepers() failed while creating keeper array; out of memory"); 651 (void) luaL_error( L, "init_keepers() failed while creating keeper array; out of memory");
diff --git a/src/lanes.c b/src/lanes.c
index 75106e9..f46046e 100644
--- a/src/lanes.c
+++ b/src/lanes.c
@@ -1133,7 +1133,7 @@ static void* linda_id( lua_State* L, enum eDeepOp op_)
1133 /* The deep data is allocated separately of Lua stack; we might no 1133 /* The deep data is allocated separately of Lua stack; we might no
1134 * longer be around when last reference to it is being released. 1134 * longer be around when last reference to it is being released.
1135 * One can use any memory allocation scheme. 1135 * One can use any memory allocation scheme.
1136 * just don't use L's allocf because we don't know which state will get the honor of GCing the linda 1136 * just don't use L's allocF because we don't know which state will get the honor of GCing the linda
1137 */ 1137 */
1138 s = (struct s_Linda*) malloc( sizeof(struct s_Linda) + name_len); // terminating 0 is already included 1138 s = (struct s_Linda*) malloc( sizeof(struct s_Linda) + name_len); // terminating 0 is already included
1139 if( s) 1139 if( s)
@@ -1545,8 +1545,8 @@ static bool_t selfdestruct_remove( struct s_lane* s)
1545*/ 1545*/
1546struct ProtectedAllocator_s 1546struct ProtectedAllocator_s
1547{ 1547{
1548 lua_Alloc allocf; 1548 lua_Alloc allocF;
1549 void* ud; 1549 void* allocUD;
1550 MUTEX_T lock; 1550 MUTEX_T lock;
1551}; 1551};
1552void * protected_lua_Alloc( void *ud, void *ptr, size_t osize, size_t nsize) 1552void * protected_lua_Alloc( void *ud, void *ptr, size_t osize, size_t nsize)
@@ -1554,7 +1554,7 @@ void * protected_lua_Alloc( void *ud, void *ptr, size_t osize, size_t nsize)
1554 void* p; 1554 void* p;
1555 struct ProtectedAllocator_s* s = (struct ProtectedAllocator_s*) ud; 1555 struct ProtectedAllocator_s* s = (struct ProtectedAllocator_s*) ud;
1556 MUTEX_LOCK( &s->lock); 1556 MUTEX_LOCK( &s->lock);
1557 p = s->allocf( s->ud, ptr, osize, nsize); 1557 p = s->allocF( s->allocUD, ptr, osize, nsize);
1558 MUTEX_UNLOCK( &s->lock); 1558 MUTEX_UNLOCK( &s->lock);
1559 return p; 1559 return p;
1560} 1560}
@@ -1700,14 +1700,14 @@ static int selfdestruct_gc( lua_State* L)
1700 // remove the protected allocator, if any 1700 // remove the protected allocator, if any
1701 { 1701 {
1702 void* ud; 1702 void* ud;
1703 lua_Alloc allocf = lua_getallocf( L, &ud); 1703 lua_Alloc allocF = lua_getallocf( L, &ud);
1704 1704
1705 if( allocf == protected_lua_Alloc) 1705 if( allocF == protected_lua_Alloc)
1706 { 1706 {
1707 struct ProtectedAllocator_s* s = (struct ProtectedAllocator_s*) ud; 1707 struct ProtectedAllocator_s* s = (struct ProtectedAllocator_s*) ud;
1708 lua_setallocf( L, s->allocf, s->ud); 1708 lua_setallocf( L, s->allocF, s->allocUD);
1709 MUTEX_FREE( &s->lock); 1709 MUTEX_FREE( &s->lock);
1710 s->allocf( s->ud, s, sizeof( struct ProtectedAllocator_s), 0); 1710 s->allocF( s->allocUD, s, sizeof( struct ProtectedAllocator_s), 0);
1711 } 1711 }
1712 } 1712 }
1713 1713
@@ -3046,13 +3046,13 @@ LUAG_FUNC( configure)
3046 lua_getfield( L, 1, "protect_allocator"); // settings protect_allocator 3046 lua_getfield( L, 1, "protect_allocator"); // settings protect_allocator
3047 if( lua_toboolean( L, -1)) 3047 if( lua_toboolean( L, -1))
3048 { 3048 {
3049 void* ud; 3049 void* allocUD;
3050 lua_Alloc allocf = lua_getallocf( L, &ud); 3050 lua_Alloc allocF = lua_getallocf( L, &allocUD);
3051 if( allocf != protected_lua_Alloc) // just in case 3051 if( allocF != protected_lua_Alloc) // just in case
3052 { 3052 {
3053 struct ProtectedAllocator_s* s = (struct ProtectedAllocator_s*) allocf( ud, NULL, 0, sizeof( struct ProtectedAllocator_s)); 3053 struct ProtectedAllocator_s* s = (struct ProtectedAllocator_s*) allocF( allocUD, NULL, 0, sizeof( struct ProtectedAllocator_s));
3054 s->allocf = allocf; 3054 s->allocF = allocF;
3055 s->ud = ud; 3055 s->allocUD = allocUD;
3056 MUTEX_INIT( &s->lock); 3056 MUTEX_INIT( &s->lock);
3057 lua_setallocf( L, protected_lua_Alloc, s); 3057 lua_setallocf( L, protected_lua_Alloc, s);
3058 } 3058 }