Comparison

util-src/crand.c @ 7823:9b66ada1487c

util.crand: Switch to luaL_checkinteger since checkint is deprecated in Lua 5.3
author Kim Alvefur <zash@zash.se>
date Fri, 20 Jan 2017 11:41:07 +0100
parent 7818:54669df178c2
child 7824:56552733742e
comparison
equal deleted inserted replaced
7821:0dea440bdd46 7823:9b66ada1487c
55 unsigned char buf[BUFLEN]; 55 unsigned char buf[BUFLEN];
56 #else 56 #else
57 unsigned char *buf; 57 unsigned char *buf;
58 #endif 58 #endif
59 int ret = 0; 59 int ret = 0;
60 size_t len = (size_t)luaL_checkint(L, 1); 60 size_t len = (size_t)luaL_checkinteger(L, 1);
61 #ifdef BUFLEN 61 #ifdef BUFLEN
62 len = len > BUFLEN ? BUFLEN : len; 62 len = len > BUFLEN ? BUFLEN : len;
63 #else 63 #else
64 buf = malloc(len); 64 buf = malloc(len);
65 65
69 /* or it migth be better to 69 /* or it migth be better to
70 * return lua_error(L); 70 * return lua_error(L);
71 */ 71 */
72 return 2; 72 return 2;
73 } 73 }
74
74 #endif 75 #endif
75 76
76 #if defined(WITH_GETRANDOM) 77 #if defined(WITH_GETRANDOM)
77 ret = getrandom(buf, len, 0); 78 ret = getrandom(buf, len, 0);
78 79