static int lupdate(lua_State *L) { struct boxstm * box = lua_touserdata(L, 1); void * msg = lua_touserdata(L, 2); uint32_t sz = luaL_checkunsigned(L, 3); stm_update(box->obj, msg, sz); return 0; }
static int lupdate(lua_State *L) { struct boxstm * box = lua_touserdata(L, 1); void * msg; size_t sz; if (lua_isuserdata(L, 2)) { msg = lua_touserdata(L, 2); sz = (size_t)luaL_checkinteger(L, 3); } else { const char * tmp = luaL_checklstring(L,2,&sz); msg = skynet_malloc(sz); memcpy(msg, tmp, sz); } stm_update(box->obj, msg, sz); return 0; }