Skip to content

Commit

Permalink
Minor tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
Benoit Germain committed Aug 16, 2023
1 parent ad7258f commit f7245f6
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 16 deletions.
4 changes: 2 additions & 2 deletions lanes-3.16.0-0.rockspec → lanes-3.16.1-0.rockspec
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@

package = "Lanes"

version = "3.16.0-0"
version = "3.16.1-0"

source= {
url= "git+https://github.com/LuaLanes/lanes.git",
branch= "v3.16.0"
branch= "v3.16.1"
}

description = {
Expand Down
2 changes: 1 addition & 1 deletion src/keeper.c
Original file line number Diff line number Diff line change
Expand Up @@ -612,7 +612,7 @@ void close_keepers( Universe* U)
// free the keeper bookkeeping structure
{
AllocatorDefinition* const allocD = &U->internal_allocator;
allocD->allocF( allocD->allocUD, U->keepers, sizeof( Keepers) + (nbKeepers - 1) * sizeof( Keeper), 0);
(void) allocD->allocF( allocD->allocUD, U->keepers, sizeof( Keepers) + (nbKeepers - 1) * sizeof( Keeper), 0);
U->keepers = NULL;
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/lanes.c
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ static void lane_cleanup( Lane* s)

{
AllocatorDefinition* const allocD = &s->U->internal_allocator;
allocD->allocF(allocD->allocUD, s, sizeof(Lane), 0);
(void) allocD->allocF(allocD->allocUD, s, sizeof(Lane), 0);
}
}

Expand Down Expand Up @@ -1225,10 +1225,10 @@ LUAG_FUNC( lane_new)
// 's' is allocated from heap, not Lua, since its life span may surpass the handle's (if free running thread)
//
// a Lane full userdata needs a single uservalue
ud = lua_newuserdatauv( L, sizeof( Lane*), 1); // func libs priority globals package required gc_cb lane
ud = lua_newuserdatauv( L, sizeof( Lane*), 1); // func libs priority globals package required gc_cb lane
{
AllocatorDefinition* const allocD = &U->internal_allocator;
s = *ud = (Lane*)allocD->allocF(allocD->allocUD, NULL, 0, sizeof(Lane));
s = *ud = (Lane*) allocD->allocF(allocD->allocUD, NULL, 0, sizeof(Lane));
}
if( s == NULL)
{
Expand Down
6 changes: 2 additions & 4 deletions src/linda.c
Original file line number Diff line number Diff line change
Expand Up @@ -797,8 +797,7 @@ static void* linda_id( lua_State* L, DeepOp op_)
{
Universe* const U = universe_get(L);
AllocatorDefinition* const allocD = &U->internal_allocator;

s = (struct s_Linda*)allocD->allocF(allocD->allocUD, NULL, 0, sizeof(struct s_Linda) + name_len); // terminating 0 is already included
s = (struct s_Linda*) allocD->allocF(allocD->allocUD, NULL, 0, sizeof(struct s_Linda) + name_len); // terminating 0 is already included
}
if( s)
{
Expand Down Expand Up @@ -835,8 +834,7 @@ static void* linda_id( lua_State* L, DeepOp op_)
{
Universe* const U = universe_get(L);
AllocatorDefinition* const allocD = &U->internal_allocator;

allocD->allocF(allocD->allocUD, linda, sizeof(struct s_Linda) + strlen(linda->name), 0);
(void) allocD->allocF(allocD->allocUD, linda, sizeof(struct s_Linda) + strlen(linda->name), 0);
}
return NULL;
}
Expand Down
2 changes: 1 addition & 1 deletion src/state.c
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ lua_State* create_state( Universe* U, lua_State* from_)
lua_pushcclosure( from_, U->provide_allocator, 0);
lua_call( from_, 0, 1);
{
AllocatorDefinition* def = lua_touserdata( from_, -1);
AllocatorDefinition* const def = lua_touserdata( from_, -1);
L = lua_newstate( def->allocF, def->allocUD);
}
lua_pop( from_, 1);
Expand Down
5 changes: 3 additions & 2 deletions src/tools.c
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ void luaG_dump( lua_State* L)

// ################################################################################################

// same as PUC-Lua l_alloc
static void* libc_lua_Alloc(void* ud, void* ptr, size_t osize, size_t nsize)
{
(void)ud; (void)osize; /* not used */
Expand Down Expand Up @@ -182,7 +183,7 @@ static void* protected_lua_Alloc( void *ud, void *ptr, size_t osize, size_t nsiz
static int luaG_provide_protected_allocator( lua_State* L)
{
Universe* U = universe_get( L);
AllocatorDefinition* def = lua_newuserdatauv( L, sizeof(AllocatorDefinition), 0);
AllocatorDefinition* const def = lua_newuserdatauv( L, sizeof(AllocatorDefinition), 0);
def->allocF = protected_lua_Alloc;
def->allocUD = &U->protected_allocator;
return 1;
Expand Down Expand Up @@ -236,7 +237,7 @@ void initialize_allocator_function( Universe* U, lua_State* L)
lua_getfield( L, -1, "internal_allocator"); // settings "libc"|"allocator"
{
char const* allocator = lua_tostring( L, -1);
if (stricmp(allocator, "libc") == 0)
if (strcmp(allocator, "libc") == 0)
{
U->internal_allocator.allocF = libc_lua_Alloc;
U->internal_allocator.allocUD = NULL;
Expand Down
2 changes: 1 addition & 1 deletion tests/basic.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
-- - ...
--

local require_lanes_result_1, require_lanes_result_2 = require "lanes".configure{ with_timers = false}
local require_lanes_result_1, require_lanes_result_2 = require "lanes".configure{ with_timers = false, internal_allocator = "libc"}
print( "require_lanes_result:", require_lanes_result_1, require_lanes_result_2)
local lanes = require_lanes_result_1

Expand Down
2 changes: 0 additions & 2 deletions tests/linda_perf.lua
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ end

local tests1 =
{
--[[
{ 10000, 2000000, 0},
{ 10000, 2000000, 1},
{ 10000, 2000000, 2},
Expand All @@ -88,7 +87,6 @@ local tests1 =
{ 10000, 2000000, 13},
{ 10000, 2000000, 21},
{ 10000, 2000000, 44},
--]]
}
print "############################################\ntests #1"
for k, v in pairs( tests1) do
Expand Down

0 comments on commit f7245f6

Please sign in to comment.