Advertisement
Guest User

Code

a guest
Jan 29th, 2019
236
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <assert.h>
  4. #include <string.h>
  5.  
  6. #include <lua/lua.h>
  7. #include <lua/lauxlib.h>
  8.  
  9. int ud_gc(lua_State *L) {
  10. return 0;
  11. }
  12.  
  13. int main(int argc, char **argv) {
  14. long long i = 0;
  15. int base;
  16. int ref = LUA_NOREF;
  17.  
  18. lua_State *L = luaL_newstate();
  19.  
  20. assert(L);
  21.  
  22. lua_createtable(L, 0, 0);
  23.  
  24. luaL_newmetatable(L, "mt");
  25. lua_pushcfunction(L, ud_gc);
  26. lua_setfield(L, -2, "__gc");
  27.  
  28. lua_pop(L, 1);
  29.  
  30. for (i = 0; i < (1UL << 24); i++) {
  31. void *ptr;
  32.  
  33. ptr = lua_newuserdata(L, 4096);
  34. luaL_setmetatable(L, "mt");
  35. ref = luaL_ref(L, 1);
  36.  
  37. luaL_unref(L, 1, ref);
  38. }
  39.  
  40. lua_close(L);
  41.  
  42. return 0;
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement