Skip to content

Commit

Permalink
udp: avoid C-style arrays
Browse files Browse the repository at this point in the history
  • Loading branch information
skypjack committed Oct 24, 2024
1 parent a3f2a6e commit 0a99349
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/uvw/udp.ipp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include <array>
#include "config.h"

namespace uvw {
Expand Down Expand Up @@ -168,8 +169,8 @@ UVW_INLINE int udp_handle::send(const socket_address &addr, char *data, unsigned
}

UVW_INLINE int udp_handle::try_send(const sockaddr &addr, std::unique_ptr<char[]> data, unsigned int len) {
uv_buf_t bufs[] = {uv_buf_init(data.get(), len)};
return uv_udp_try_send(raw(), bufs, 1, &addr);
std::array bufs{uv_buf_init(data.get(), len)};
return uv_udp_try_send(raw(), bufs.data(), 1, &addr);
}

UVW_INLINE int udp_handle::try_send(const std::string &ip, unsigned int port, std::unique_ptr<char[]> data, unsigned int len) {
Expand All @@ -181,8 +182,8 @@ UVW_INLINE int udp_handle::try_send(const socket_address &addr, std::unique_ptr<
}

UVW_INLINE int udp_handle::try_send(const sockaddr &addr, char *data, unsigned int len) {
uv_buf_t bufs[] = {uv_buf_init(data, len)};
return uv_udp_try_send(raw(), bufs, 1, &addr);
std::array bufs{uv_buf_init(data, len)};
return uv_udp_try_send(raw(), bufs.data(), 1, &addr);
}

UVW_INLINE int udp_handle::try_send(const std::string &ip, unsigned int port, char *data, unsigned int len) {
Expand Down

0 comments on commit 0a99349

Please sign in to comment.