Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <assert.h>
- #include <lua.h>
- #include <lauxlib.h>
- #include <lualib.h>
- #include <zmq.h>
- const char *lua_code =
- "local zmq = require \"lzmq\""
- "local ctx = zmq.init_ctx(MY_ZMQ_CONTEXT)"
- "print(\"creating socket...\")"
- "local s = ctx:socket(zmq.REP)" // segmentation fault
- "print(\"created socket!\")"
- ;
- int main()
- {
- int r;
- void *ctx;
- ctx = zmq_ctx_new();
- assert(ctx);
- lua_State *L;
- L = luaL_newstate();
- assert(L);
- luaL_requiref(L, "_G", luaopen_base, 1);
- luaL_requiref(L, "package", luaopen_package, 1);
- lua_pop(L, 2);
- lua_pushlightuserdata(L, ctx);
- lua_setglobal(L, "MY_ZMQ_CONTEXT");
- luaL_dostring(L, lua_code);
- lua_close(L);
- r = zmq_ctx_destroy(ctx);
- assert(r == 0);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement