Skip to content

Commit

Permalink
uv_handle_size() instead of sizeof(*handle)
Browse files Browse the repository at this point in the history
  • Loading branch information
sidaxx committed Sep 29, 2021
1 parent 0e9d8d8 commit fafd315
Show file tree
Hide file tree
Showing 14 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/async.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ static int luv_new_async(lua_State* L) {
int ret;
luv_ctx_t* ctx = luv_context(L);
luaL_checktype(L, 1, LUA_TFUNCTION);
handle = (uv_async_t*)luv_newuserdata(L, sizeof(*handle));
handle = (uv_async_t*)luv_newuserdata(L, uv_handle_size(UV_ASYNC));
ret = uv_async_init(ctx->loop, handle, luv_async_cb);
if (ret < 0) {
lua_pop(L, 1);
Expand Down
2 changes: 1 addition & 1 deletion src/check.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ static uv_check_t* luv_check_check(lua_State* L, int index) {

static int luv_new_check(lua_State* L) {
luv_ctx_t* ctx = luv_context(L);
uv_check_t* handle = (uv_check_t*)luv_newuserdata(L, sizeof(*handle));
uv_check_t* handle = (uv_check_t*)luv_newuserdata(L, uv_handle_size(UV_CHECK));
int ret = uv_check_init(ctx->loop, handle);
if (ret < 0) {
lua_pop(L, 1);
Expand Down
2 changes: 1 addition & 1 deletion src/fs_event.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ static uv_fs_event_t* luv_check_fs_event(lua_State* L, int index) {

static int luv_new_fs_event(lua_State* L) {
luv_ctx_t* ctx = luv_context(L);
uv_fs_event_t* handle = (uv_fs_event_t*)luv_newuserdata(L, sizeof(*handle));
uv_fs_event_t* handle = (uv_fs_event_t*)luv_newuserdata(L, uv_handle_size(UV_FS_EVENT));
int ret = uv_fs_event_init(ctx->loop, handle);
if (ret < 0) {
lua_pop(L, 1);
Expand Down
2 changes: 1 addition & 1 deletion src/fs_poll.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ static uv_fs_poll_t* luv_check_fs_poll(lua_State* L, int index) {

static int luv_new_fs_poll(lua_State* L) {
luv_ctx_t* ctx = luv_context(L);
uv_fs_poll_t* handle = (uv_fs_poll_t*)luv_newuserdata(L, sizeof(*handle));
uv_fs_poll_t* handle = (uv_fs_poll_t*)luv_newuserdata(L, uv_handle_size(UV_FS_POLL));
int ret = uv_fs_poll_init(ctx->loop, handle);
if (ret < 0) {
lua_pop(L, 1);
Expand Down
2 changes: 1 addition & 1 deletion src/idle.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ static uv_idle_t* luv_check_idle(lua_State* L, int index) {

static int luv_new_idle(lua_State* L) {
luv_ctx_t* ctx = luv_context(L);
uv_idle_t* handle = (uv_idle_t*)luv_newuserdata(L, sizeof(*handle));
uv_idle_t* handle = (uv_idle_t*)luv_newuserdata(L, uv_handle_size(UV_IDLE));
int ret = uv_idle_init(ctx->loop, handle);
if (ret < 0) {
lua_pop(L, 1);
Expand Down
2 changes: 1 addition & 1 deletion src/pipe.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ static int luv_new_pipe(lua_State* L) {
int ipc, ret;
luv_ctx_t* ctx = luv_context(L);
ipc = luv_optboolean(L, 1, 0);
handle = (uv_pipe_t*)luv_newuserdata(L, sizeof(*handle));
handle = (uv_pipe_t*)luv_newuserdata(L, uv_handle_size(UV_NAMED_PIPE));
ret = uv_pipe_init(ctx->loop, handle, ipc);
if (ret < 0) {
lua_pop(L, 1);
Expand Down
4 changes: 2 additions & 2 deletions src/poll.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ static uv_poll_t* luv_check_poll(lua_State* L, int index) {
static int luv_new_poll(lua_State* L) {
luv_ctx_t* ctx = luv_context(L);
int fd = luaL_checkinteger(L, 1);
uv_poll_t* handle = (uv_poll_t*)luv_newuserdata(L, sizeof(*handle));
uv_poll_t* handle = (uv_poll_t*)luv_newuserdata(L, uv_handle_size(UV_POLL));
int ret = uv_poll_init(ctx->loop, handle, fd);
if (ret < 0) {
lua_pop(L, 1);
Expand All @@ -38,7 +38,7 @@ static int luv_new_poll(lua_State* L) {
static int luv_new_socket_poll(lua_State* L) {
luv_ctx_t* ctx = luv_context(L);
int fd = luaL_checkinteger(L, 1);
uv_poll_t* handle = (uv_poll_t*)luv_newuserdata(L, sizeof(*handle));
uv_poll_t* handle = (uv_poll_t*)luv_newuserdata(L, uv_handle_size(UV_POLL));
int ret = uv_poll_init_socket(ctx->loop, handle, fd);
if (ret < 0) {
lua_pop(L, 1);
Expand Down
2 changes: 1 addition & 1 deletion src/prepare.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ static uv_prepare_t* luv_check_prepare(lua_State* L, int index) {

static int luv_new_prepare(lua_State* L) {
luv_ctx_t* ctx = luv_context(L);
uv_prepare_t* handle = (uv_prepare_t*)luv_newuserdata(L, sizeof(*handle));
uv_prepare_t* handle = (uv_prepare_t*)luv_newuserdata(L, uv_handle_size(UV_PREPARE));
int ret = uv_prepare_init(ctx->loop, handle);
if (ret < 0) {
lua_pop(L, 1);
Expand Down
2 changes: 1 addition & 1 deletion src/process.c
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ static int luv_spawn(lua_State* L) {
// the uv_process_t userdata doesn't get treated as the 3rd argument
lua_settop(L, 3);

handle = (uv_process_t*)luv_newuserdata(L, sizeof(*handle));
handle = (uv_process_t*)luv_newuserdata(L, uv_handle_size(UV_PROCESS));
handle->type = UV_PROCESS;
handle->data = luv_setup_handle(L, ctx);

Expand Down
2 changes: 1 addition & 1 deletion src/signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ static uv_signal_t* luv_check_signal(lua_State* L, int index) {

static int luv_new_signal(lua_State* L) {
luv_ctx_t* ctx = luv_context(L);
uv_signal_t* handle = (uv_signal_t*)luv_newuserdata(L, sizeof(*handle));
uv_signal_t* handle = (uv_signal_t*)luv_newuserdata(L, uv_handle_size(UV_SIGNAL));
int ret = uv_signal_init(ctx->loop, handle);
if (ret < 0) {
lua_pop(L, 1);
Expand Down
2 changes: 1 addition & 1 deletion src/tcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ static int luv_new_tcp(lua_State* L) {
int ret;
luv_ctx_t* ctx = luv_context(L);
lua_settop(L, 1);
handle = (uv_tcp_t*)luv_newuserdata(L, sizeof(*handle));
handle = (uv_tcp_t*)luv_newuserdata(L, uv_handle_size(UV_TCP));
#if LUV_UV_VERSION_GEQ(1, 7, 0)
if (lua_isnoneornil(L, 1)) {
ret = uv_tcp_init(ctx->loop, handle);
Expand Down
2 changes: 1 addition & 1 deletion src/timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ static uv_timer_t* luv_check_timer(lua_State* L, int index) {

static int luv_new_timer(lua_State* L) {
luv_ctx_t* ctx = luv_context(L);
uv_timer_t* handle = (uv_timer_t*) luv_newuserdata(L, sizeof(*handle));
uv_timer_t* handle = (uv_timer_t*) luv_newuserdata(L, uv_handle_size(UV_TIMER));
int ret = uv_timer_init(ctx->loop, handle);
if (ret < 0) {
lua_pop(L, 1);
Expand Down
2 changes: 1 addition & 1 deletion src/tty.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ static int luv_new_tty(lua_State* L) {
uv_file fd = luaL_checkinteger(L, 1);
luaL_checktype(L, 2, LUA_TBOOLEAN);
readable = lua_toboolean(L, 2);
handle = (uv_tty_t*)luv_newuserdata(L, sizeof(*handle));
handle = (uv_tty_t*)luv_newuserdata(L, uv_handle_size(UV_TTY));
ret = uv_tty_init(ctx->loop, handle, fd, readable);
if (ret < 0) {
lua_pop(L, 1);
Expand Down
2 changes: 1 addition & 1 deletion src/udp.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ static uv_udp_t* luv_check_udp(lua_State* L, int index) {
static int luv_new_udp(lua_State* L) {
luv_ctx_t* ctx = luv_context(L);
lua_settop(L, 1);
uv_udp_t* handle = (uv_udp_t*)luv_newuserdata(L, sizeof(*handle));
uv_udp_t* handle = (uv_udp_t*)luv_newuserdata(L, uv_handle_size(UV_UDP));
int ret;
#if LUV_UV_VERSION_GEQ(1, 39, 0)
// TODO: This default can potentially be increased, but it's
Expand Down

0 comments on commit fafd315

Please sign in to comment.