aboutsummaryrefslogtreecommitdiff
path: root/src/lanes.c
diff options
context:
space:
mode:
authorBenoit Germain <bnt period germain arrobase gmail period com>2014-03-17 09:35:05 +0100
committerBenoit Germain <bnt period germain arrobase gmail period com>2014-03-17 09:35:05 +0100
commit0ffafefaf5ef410fa0da95ac1860e817428531ed (patch)
treed1cadd12607a3915509dfe3bec0331dfca388820 /src/lanes.c
parent9e55f96ac685929a11681b9c98710c94eeb2e18a (diff)
downloadlanes-0ffafefaf5ef410fa0da95ac1860e817428531ed.tar.gz
lanes-0ffafefaf5ef410fa0da95ac1860e817428531ed.tar.bz2
lanes-0ffafefaf5ef410fa0da95ac1860e817428531ed.zip
Fixed crash when using protect_allocator option
Diffstat (limited to 'src/lanes.c')
-rw-r--r--src/lanes.c28
1 files changed, 14 insertions, 14 deletions
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 }