Skip to content

Commit 935bb1d

Browse files
committed
Use std::array over C-style arrays for kevent event list
1 parent a1ad4f5 commit 935bb1d

2 files changed

Lines changed: 3 additions & 2 deletions

File tree

src/HTTPServer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ void HTTPServer::process() {
206206
while (canRun) {
207207
// Get a list of changed socket descriptors with a read event triggered in evList
208208
// Timeout set in the header
209-
nev = kevent(kqfd, NULL, 0, evList, QUEUE_SIZE, &kqTimeout);
209+
nev = kevent(kqfd, NULL, 0, evList.data(), QUEUE_SIZE, &kqTimeout);
210210

211211
if (nev <= 0)
212212
continue;

src/HTTPServer.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include "HTTPResponse.h"
2525
#include "ResourceHost.h"
2626

27+
#include <array>
2728
#include <memory>
2829
#include <unordered_map>
2930
#include <vector>
@@ -51,7 +52,7 @@ class HTTPServer {
5152
// Kqueue
5253
struct timespec kqTimeout = {2, 0}; // Block for 2 seconds and 0ns at the most
5354
int32_t kqfd = -1; // kqueue descriptor
54-
struct kevent evList[QUEUE_SIZE]; // Events that have triggered a filter in the kqueue (max QUEUE_SIZE at a time)
55+
std::array<struct kevent, QUEUE_SIZE> evList; // Events that have triggered a filter in the kqueue (max QUEUE_SIZE at a time)
5556

5657
// Client map, maps Socket descriptor to Client object
5758
std::unordered_map<int, std::shared_ptr<Client>> clientMap;

0 commit comments

Comments
 (0)