aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/keeper.c2
-rw-r--r--src/lanes.c6
-rw-r--r--src/linda.c6
-rw-r--r--src/state.c2
-rw-r--r--src/tools.c5
5 files changed, 10 insertions, 11 deletions
diff --git a/src/keeper.c b/src/keeper.c
index f4dde0a..8aa734a 100644
--- a/src/keeper.c
+++ b/src/keeper.c
@@ -612,7 +612,7 @@ void close_keepers( Universe* U)
612 // free the keeper bookkeeping structure 612 // free the keeper bookkeeping structure
613 { 613 {
614 AllocatorDefinition* const allocD = &U->internal_allocator; 614 AllocatorDefinition* const allocD = &U->internal_allocator;
615 allocD->allocF( allocD->allocUD, U->keepers, sizeof( Keepers) + (nbKeepers - 1) * sizeof( Keeper), 0); 615 (void) allocD->allocF( allocD->allocUD, U->keepers, sizeof( Keepers) + (nbKeepers - 1) * sizeof( Keeper), 0);
616 U->keepers = NULL; 616 U->keepers = NULL;
617 } 617 }
618 } 618 }
diff --git a/src/lanes.c b/src/lanes.c
index 0aab244..d2c95ee 100644
--- a/src/lanes.c
+++ b/src/lanes.c
@@ -255,7 +255,7 @@ static void lane_cleanup( Lane* s)
255 255
256 { 256 {
257 AllocatorDefinition* const allocD = &s->U->internal_allocator; 257 AllocatorDefinition* const allocD = &s->U->internal_allocator;
258 allocD->allocF(allocD->allocUD, s, sizeof(Lane), 0); 258 (void) allocD->allocF(allocD->allocUD, s, sizeof(Lane), 0);
259 } 259 }
260} 260}
261 261
@@ -1225,10 +1225,10 @@ LUAG_FUNC( lane_new)
1225 // 's' is allocated from heap, not Lua, since its life span may surpass the handle's (if free running thread) 1225 // 's' is allocated from heap, not Lua, since its life span may surpass the handle's (if free running thread)
1226 // 1226 //
1227 // a Lane full userdata needs a single uservalue 1227 // a Lane full userdata needs a single uservalue
1228 ud = lua_newuserdatauv( L, sizeof( Lane*), 1); // func libs priority globals package required gc_cb lane 1228 ud = lua_newuserdatauv( L, sizeof( Lane*), 1); // func libs priority globals package required gc_cb lane
1229 { 1229 {
1230 AllocatorDefinition* const allocD = &U->internal_allocator; 1230 AllocatorDefinition* const allocD = &U->internal_allocator;
1231 s = *ud = (Lane*)allocD->allocF(allocD->allocUD, NULL, 0, sizeof(Lane)); 1231 s = *ud = (Lane*) allocD->allocF(allocD->allocUD, NULL, 0, sizeof(Lane));
1232 } 1232 }
1233 if( s == NULL) 1233 if( s == NULL)
1234 { 1234 {
diff --git a/src/linda.c b/src/linda.c
index 390816b..8b59790 100644
--- a/src/linda.c
+++ b/src/linda.c
@@ -797,8 +797,7 @@ static void* linda_id( lua_State* L, DeepOp op_)
797 { 797 {
798 Universe* const U = universe_get(L); 798 Universe* const U = universe_get(L);
799 AllocatorDefinition* const allocD = &U->internal_allocator; 799 AllocatorDefinition* const allocD = &U->internal_allocator;
800 800 s = (struct s_Linda*) allocD->allocF(allocD->allocUD, NULL, 0, sizeof(struct s_Linda) + name_len); // terminating 0 is already included
801 s = (struct s_Linda*)allocD->allocF(allocD->allocUD, NULL, 0, sizeof(struct s_Linda) + name_len); // terminating 0 is already included
802 } 801 }
803 if( s) 802 if( s)
804 { 803 {
@@ -835,8 +834,7 @@ static void* linda_id( lua_State* L, DeepOp op_)
835 { 834 {
836 Universe* const U = universe_get(L); 835 Universe* const U = universe_get(L);
837 AllocatorDefinition* const allocD = &U->internal_allocator; 836 AllocatorDefinition* const allocD = &U->internal_allocator;
838 837 (void) allocD->allocF(allocD->allocUD, linda, sizeof(struct s_Linda) + strlen(linda->name), 0);
839 allocD->allocF(allocD->allocUD, linda, sizeof(struct s_Linda) + strlen(linda->name), 0);
840 } 838 }
841 return NULL; 839 return NULL;
842 } 840 }
diff --git a/src/state.c b/src/state.c
index ef70842..21ca397 100644
--- a/src/state.c
+++ b/src/state.c
@@ -259,7 +259,7 @@ lua_State* create_state( Universe* U, lua_State* from_)
259 lua_pushcclosure( from_, U->provide_allocator, 0); 259 lua_pushcclosure( from_, U->provide_allocator, 0);
260 lua_call( from_, 0, 1); 260 lua_call( from_, 0, 1);
261 { 261 {
262 AllocatorDefinition* def = lua_touserdata( from_, -1); 262 AllocatorDefinition* const def = lua_touserdata( from_, -1);
263 L = lua_newstate( def->allocF, def->allocUD); 263 L = lua_newstate( def->allocF, def->allocUD);
264 } 264 }
265 lua_pop( from_, 1); 265 lua_pop( from_, 1);
diff --git a/src/tools.c b/src/tools.c
index 5a6ae92..80e0f71 100644
--- a/src/tools.c
+++ b/src/tools.c
@@ -155,6 +155,7 @@ void luaG_dump( lua_State* L)
155 155
156// ################################################################################################ 156// ################################################################################################
157 157
158// same as PUC-Lua l_alloc
158static void* libc_lua_Alloc(void* ud, void* ptr, size_t osize, size_t nsize) 159static void* libc_lua_Alloc(void* ud, void* ptr, size_t osize, size_t nsize)
159{ 160{
160 (void)ud; (void)osize; /* not used */ 161 (void)ud; (void)osize; /* not used */
@@ -182,7 +183,7 @@ static void* protected_lua_Alloc( void *ud, void *ptr, size_t osize, size_t nsiz
182static int luaG_provide_protected_allocator( lua_State* L) 183static int luaG_provide_protected_allocator( lua_State* L)
183{ 184{
184 Universe* U = universe_get( L); 185 Universe* U = universe_get( L);
185 AllocatorDefinition* def = lua_newuserdatauv( L, sizeof(AllocatorDefinition), 0); 186 AllocatorDefinition* const def = lua_newuserdatauv( L, sizeof(AllocatorDefinition), 0);
186 def->allocF = protected_lua_Alloc; 187 def->allocF = protected_lua_Alloc;
187 def->allocUD = &U->protected_allocator; 188 def->allocUD = &U->protected_allocator;
188 return 1; 189 return 1;
@@ -236,7 +237,7 @@ void initialize_allocator_function( Universe* U, lua_State* L)
236 lua_getfield( L, -1, "internal_allocator"); // settings "libc"|"allocator" 237 lua_getfield( L, -1, "internal_allocator"); // settings "libc"|"allocator"
237 { 238 {
238 char const* allocator = lua_tostring( L, -1); 239 char const* allocator = lua_tostring( L, -1);
239 if (stricmp(allocator, "libc") == 0) 240 if (strcmp(allocator, "libc") == 0)
240 { 241 {
241 U->internal_allocator.allocF = libc_lua_Alloc; 242 U->internal_allocator.allocF = libc_lua_Alloc;
242 U->internal_allocator.allocUD = NULL; 243 U->internal_allocator.allocUD = NULL;