Skip to content

Commit

Permalink
[core] Remove use variable length array (#2279).
Browse files Browse the repository at this point in the history
Use srt::FixedArray.

Co-authored-by: Maxim Sharabayko <maxlovic@gmail.com>
  • Loading branch information
quink-black and maxsharabayko committed Dec 8, 2022
1 parent b6f1e9c commit 38b4211
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions srtcore/epoll.cpp
Expand Up @@ -66,6 +66,7 @@ modified by
#include "epoll.h"
#include "logging.h"
#include "udt.h"
#include "utilities.h"

using namespace std;
using namespace srt::sync;
Expand Down Expand Up @@ -639,8 +640,8 @@ int srt::CEPoll::wait(const int eid, set<SRTSOCKET>* readfds, set<SRTSOCKET>* wr
#ifdef LINUX
const int max_events = ed.m_sLocals.size();
SRT_ASSERT(max_events > 0);
epoll_event ev[max_events];
int nfds = ::epoll_wait(ed.m_iLocalID, ev, max_events, 0);
srt::FixedArray<epoll_event> ev(max_events);
int nfds = ::epoll_wait(ed.m_iLocalID, ev.data(), ev.size(), 0);

IF_HEAVY_LOGGING(const int prev_total = total);
for (int i = 0; i < nfds; ++ i)
Expand All @@ -662,9 +663,9 @@ int srt::CEPoll::wait(const int eid, set<SRTSOCKET>* readfds, set<SRTSOCKET>* wr
struct timespec tmout = {0, 0};
const int max_events = ed.m_sLocals.size();
SRT_ASSERT(max_events > 0);
struct kevent ke[max_events];
srt::FixedArray<struct kevent> ke(max_events);

int nfds = kevent(ed.m_iLocalID, NULL, 0, ke, max_events, &tmout);
int nfds = kevent(ed.m_iLocalID, NULL, 0, ke.data(), ke.size(), &tmout);
IF_HEAVY_LOGGING(const int prev_total = total);

for (int i = 0; i < nfds; ++ i)
Expand Down

0 comments on commit 38b4211

Please sign in to comment.