From 25cd3d377ec13176a6701d9d21a278ba8f2bc3d6 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Wed, 15 Nov 2023 10:28:32 -0300 Subject: Buffer in 'luai_makeseed' measured in bytes In the (rare) cases when sizeof(void*) or sizeof(time_t) are not multiples of sizeof(int), we still can use all their bytes in the seed. --- ltests.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'ltests.c') diff --git a/ltests.c b/ltests.c index 94bd4e33..bd4147f2 100644 --- a/ltests.c +++ b/ltests.c @@ -1160,6 +1160,12 @@ static int num2int (lua_State *L) { } +static int makeseed (lua_State *L) { + lua_pushinteger(L, luaL_makeseed(L)); + return 1; +} + + static int newstate (lua_State *L) { void *ud; lua_Alloc f = lua_getallocf(L, &ud); @@ -1962,6 +1968,7 @@ static const struct luaL_Reg tests_funcs[] = { {"newstate", newstate}, {"newuserdata", newuserdata}, {"num2int", num2int}, + {"makeseed", makeseed}, {"pushuserdata", pushuserdata}, {"querystr", string_query}, {"querytab", table_query}, -- cgit v1.2.3-55-g6feb