Guest User

Lua 5.3 - Strings

a guest
Feb 1st, 2019
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <assert.h>
  4.  
  5. #include <unistd.h>
  6. #include <fcntl.h>
  7.  
  8. #include <lua/lua.h>
  9. #include <lua/lauxlib.h>
  10. #include <lua/lualib.h>
  11.  
  12. int main(int argc, char **argv) {
  13. long long i = 0;
  14. int superbigref = LUA_NOREF;
  15. char *superbig = malloc(4096);
  16. int fd = open("/dev/urandom", O_RDWR);
  17.  
  18. lua_State *L = luaL_newstate();
  19.  
  20. luaL_openlibs(L);
  21.  
  22. assert(superbig); assert(L);
  23.  
  24. lua_createtable(L, 0, 0);
  25.  
  26. for (i = 0; i < (1UL << 19); i++) {
  27. read(fd, superbig, 4096);
  28.  
  29. lua_pushlstring(L, superbig, 4096);
  30. superbigref = luaL_ref(L, 1);
  31.  
  32. luaL_unref(L, 1, superbigref);
  33. }
  34.  
  35. lua_close(L);
  36.  
  37. return 0;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment