ext/libuv/test/test-shutdown-eof.c in libuv-0.10.2 vs ext/libuv/test/test-shutdown-eof.c in libuv-0.10.3

- old
+ new

@@ -37,37 +37,35 @@ static int called_tcp_close_cb; static int called_timer_close_cb; static int called_timer_cb; -static uv_buf_t alloc_cb(uv_handle_t* handle, size_t size) { - uv_buf_t buf; - buf.base = (char*)malloc(size); - buf.len = size; - return buf; +static void alloc_cb(uv_handle_t* handle, size_t size, uv_buf_t* buf) { + buf->base = malloc(size); + buf->len = size; } -static void read_cb(uv_stream_t* t, ssize_t nread, uv_buf_t buf) { +static void read_cb(uv_stream_t* t, ssize_t nread, const uv_buf_t* buf) { ASSERT((uv_tcp_t*)t == &tcp); if (nread == 0) { - free(buf.base); + free(buf->base); return; } if (!got_q) { ASSERT(nread == 1); ASSERT(!got_eof); - ASSERT(buf.base[0] == 'Q'); - free(buf.base); + ASSERT(buf->base[0] == 'Q'); + free(buf->base); got_q = 1; puts("got Q"); } else { ASSERT(nread == UV_EOF); - if (buf.base) { - free(buf.base); + if (buf->base) { + free(buf->base); } got_eof = 1; puts("got EOF"); } } @@ -156,14 +154,17 @@ r = uv_timer_init(uv_default_loop(), &timer); ASSERT(r == 0); uv_timer_start(&timer, timer_cb, 100, 0); - server_addr = uv_ip4_addr("127.0.0.1", TEST_PORT); + ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &server_addr)); r = uv_tcp_init(uv_default_loop(), &tcp); ASSERT(!r); - r = uv_tcp_connect(&connect_req, &tcp, server_addr, connect_cb); + r = uv_tcp_connect(&connect_req, + &tcp, + (const struct sockaddr*) &server_addr, + connect_cb); ASSERT(!r); uv_run(uv_default_loop(), UV_RUN_DEFAULT); ASSERT(called_connect_cb == 1);