Commit 4fe23efc authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

input: avoid heap-allocation in vlc_poll_i11e() in most cases

parent 2bd02c89
......@@ -328,6 +328,14 @@ int vlc_poll_i11e(struct pollfd *fds, unsigned nfds, int timeout)
int ret;
if (likely(nfds < 255))
{ /* Fast path with stack allocation */
struct pollfd ufd[nfds + 1];
ret = vlc_poll_i11e_inner(fds, nfds, timeout, ctx, ufd);
}
else
{ /* Slow path but poll() is slow with large nfds anyway. */
struct pollfd *ufd = malloc((nfds + 1) * sizeof (*ufd));
if (unlikely(ufd == NULL))
return -1; /* ENOMEM */
......@@ -336,6 +344,7 @@ int vlc_poll_i11e(struct pollfd *fds, unsigned nfds, int timeout)
ret = vlc_poll_i11e_inner(fds, nfds, timeout, ctx, ufd);
vlc_cleanup_pop();
free(ufd);
}
return ret;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment