s3:lib: avoid talloc_zero_array() in poll_one_fd()
authorStefan Metzmacher <metze@samba.org>
Wed, 4 Dec 2013 22:31:10 +0000 (23:31 +0100)
committerVolker Lendecke <vl@samba.org>
Sat, 14 Dec 2013 15:24:48 +0000 (16:24 +0100)
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
source3/lib/util_sock.c

index a35ae97eba28faa30fc31bc7d1182e6a0601f021..12e4ccdccefef67aefede4ec791c65aa8faaabc7 100644 (file)
@@ -1490,27 +1490,18 @@ int getaddrinfo_recv(struct tevent_req *req, struct addrinfo **res)
 
 int poll_one_fd(int fd, int events, int timeout, int *revents)
 {
-       struct pollfd *fds;
+       struct pollfd pfd;
        int ret;
-       int saved_errno;
 
-       fds = talloc_zero_array(talloc_tos(), struct pollfd, 1);
-       if (fds == NULL) {
-               errno = ENOMEM;
-               return -1;
-       }
-       fds[0].fd = fd;
-       fds[0].events = events;
+       pfd.fd = fd;
+       pfd.events = events;
 
-       ret = poll(fds, 1, timeout);
+       ret = poll(&pfd, 1, timeout);
 
        /*
         * Assign whatever poll did, even in the ret<=0 case.
         */
-       *revents = fds[0].revents;
-       saved_errno = errno;
-       TALLOC_FREE(fds);
-       errno = saved_errno;
+       *revents = pfd.revents;
 
        return ret;
 }