From 2885d4471440c791c72beec665976471cf66ea77 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Alexis=20Laferri=C3=A8re?= Date: Fri, 26 Dec 2014 16:35:17 -0500 Subject: [PATCH] lib/socket: make `NativeSocketPollFD` a pointer MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Alexis Laferrière --- lib/socket/socket_c.nit | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/lib/socket/socket_c.nit b/lib/socket/socket_c.nit index c68dd92..793b1c5 100644 --- a/lib/socket/socket_c.nit +++ b/lib/socket/socket_c.nit @@ -79,24 +79,23 @@ class PollFD end # Data structure used by the poll function -private extern class NativeSocketPollFD `{ struct pollfd `} +private extern class NativeSocketPollFD `{ struct pollfd * `} - # File descriptor id - private fun fd: Int `{ return recv.fd; `} + # File descriptor + fun fd: Int `{ return recv->fd; `} # List of events to be watched - private fun events: Int `{ return recv.events; `} + fun events: Int `{ return recv->events; `} # List of events received by the last poll function - private fun revents: Int `{ return recv.revents; `} + fun revents: Int `{ return recv->revents; `} new (pid: Int, events: NativeSocketPollValues) `{ - struct pollfd poll; - poll.fd = pid; - poll.events = events; + struct pollfd *poll = malloc(sizeof(struct pollfd)); + poll->fd = pid; + poll->events = events; return poll; `} - end extern class NativeSocket `{ int* `} @@ -177,7 +176,7 @@ extern class NativeSocket `{ int* `} # The array's members are pollfd structures within which fd specifies an open file descriptor and events and revents are bitmasks constructed by # OR'ing a combination of the pollfd flags. private fun native_poll(filedesc: NativeSocketPollFD, timeout: Int): Int `{ - int poll_return = poll(&filedesc, 1, timeout); + int poll_return = poll(filedesc, 1, timeout); return poll_return; `} -- 1.7.9.5