src: Move array_size to nghttp2 namespace
This commit is contained in:
parent
33879219ff
commit
6ff67ae869
|
@ -148,14 +148,14 @@ void Http2Session::on_connect() {
|
|||
|
||||
nghttp2_session_client_new(&session_, callbacks, client_);
|
||||
|
||||
nghttp2_settings_entry iv[2];
|
||||
std::array<nghttp2_settings_entry, 2> iv;
|
||||
iv[0].settings_id = NGHTTP2_SETTINGS_ENABLE_PUSH;
|
||||
iv[0].value = 0;
|
||||
iv[1].settings_id = NGHTTP2_SETTINGS_INITIAL_WINDOW_SIZE;
|
||||
iv[1].value = (1 << client_->worker->config->window_bits) - 1;
|
||||
|
||||
rv = nghttp2_submit_settings(session_, NGHTTP2_FLAG_NONE, iv,
|
||||
util::array_size(iv));
|
||||
rv = nghttp2_submit_settings(session_, NGHTTP2_FLAG_NONE, iv.data(),
|
||||
iv.size());
|
||||
|
||||
assert(rv == 0);
|
||||
|
||||
|
|
|
@ -124,12 +124,11 @@ void SpdySession::on_connect() {
|
|||
spdylay_session_set_option(session_, SPDYLAY_OPT_NO_AUTO_WINDOW_UPDATE, &val,
|
||||
sizeof(val));
|
||||
|
||||
spdylay_settings_entry iv[1];
|
||||
iv[0].settings_id = SPDYLAY_SETTINGS_INITIAL_WINDOW_SIZE;
|
||||
iv[0].flags = SPDYLAY_ID_FLAG_SETTINGS_NONE;
|
||||
iv[0].value = (1 << client_->worker->config->window_bits);
|
||||
spdylay_submit_settings(session_, SPDYLAY_FLAG_SETTINGS_NONE, iv,
|
||||
util::array_size(iv));
|
||||
spdylay_settings_entry iv;
|
||||
iv.settings_id = SPDYLAY_SETTINGS_INITIAL_WINDOW_SIZE;
|
||||
iv.flags = SPDYLAY_ID_FLAG_SETTINGS_NONE;
|
||||
iv.value = (1 << client_->worker->config->window_bits);
|
||||
spdylay_submit_settings(session_, SPDYLAY_FLAG_SETTINGS_NONE, &iv, 1);
|
||||
|
||||
auto config = client_->worker->config;
|
||||
|
||||
|
|
|
@ -154,8 +154,8 @@ void test_memchunks_riovec(void) {
|
|||
|
||||
chunks.append(buf, sizeof(buf));
|
||||
|
||||
struct iovec iov[2];
|
||||
auto iovcnt = chunks.riovec(iov, util::array_size(iov));
|
||||
std::array<struct iovec, 2> iov;
|
||||
auto iovcnt = chunks.riovec(iov.data(), iov.size());
|
||||
|
||||
auto m = chunks.head;
|
||||
|
||||
|
@ -170,7 +170,7 @@ void test_memchunks_riovec(void) {
|
|||
|
||||
chunks.drain(2 * 16);
|
||||
|
||||
iovcnt = chunks.riovec(iov, util::array_size(iov));
|
||||
iovcnt = chunks.riovec(iov.data(), iov.size());
|
||||
|
||||
CU_ASSERT(1 == iovcnt);
|
||||
|
||||
|
|
|
@ -713,12 +713,12 @@ int HttpDownstreamConnection::on_write() {
|
|||
auto upstream = downstream_->get_upstream();
|
||||
auto input = downstream_->get_request_buf();
|
||||
|
||||
struct iovec iov[MAX_WR_IOVCNT];
|
||||
std::array<struct iovec, MAX_WR_IOVCNT> iov;
|
||||
|
||||
while (input->rleft() > 0) {
|
||||
auto iovcnt = input->riovec(iov, util::array_size(iov));
|
||||
auto iovcnt = input->riovec(iov.data(), iov.size());
|
||||
|
||||
auto nwrite = conn_.writev_clear(iov, iovcnt);
|
||||
auto nwrite = conn_.writev_clear(iov.data(), iovcnt);
|
||||
|
||||
if (nwrite == 0) {
|
||||
return 0;
|
||||
|
|
|
@ -39,6 +39,7 @@
|
|||
#include "shrpx_downstream.h"
|
||||
#include "shrpx_worker_config.h"
|
||||
#include "util.h"
|
||||
#include "template.h"
|
||||
|
||||
using namespace nghttp2;
|
||||
|
||||
|
@ -63,7 +64,7 @@ int Log::severity_thres_ = NOTICE;
|
|||
void Log::set_severity_level(int severity) { severity_thres_ = severity; }
|
||||
|
||||
int Log::set_severity_level_by_name(const char *name) {
|
||||
for (size_t i = 0, max = util::array_size(SEVERITY_STR); i < max; ++i) {
|
||||
for (size_t i = 0, max = array_size(SEVERITY_STR); i < max; ++i) {
|
||||
if (strcmp(SEVERITY_STR[i], name) == 0) {
|
||||
severity_thres_ = i;
|
||||
return 0;
|
||||
|
|
|
@ -267,7 +267,7 @@ int alpn_select_proto_cb(SSL *ssl, const unsigned char **out,
|
|||
|
||||
namespace {
|
||||
const char *tls_names[] = {"TLSv1.2", "TLSv1.1", "TLSv1.0"};
|
||||
const size_t tls_namelen = util::array_size(tls_names);
|
||||
const size_t tls_namelen = array_size(tls_names);
|
||||
const long int tls_masks[] = {SSL_OP_NO_TLSv1_2, SSL_OP_NO_TLSv1_1,
|
||||
SSL_OP_NO_TLSv1};
|
||||
} // namespace
|
||||
|
|
|
@ -50,7 +50,7 @@ void test_shrpx_ssl_create_lookup_tree(void) {
|
|||
"sourceforge.net", // duplicate
|
||||
"*.foo.bar", // oo.bar is suffix of *.foo.bar
|
||||
"oo.bar"};
|
||||
int num = util::array_size(ctxs);
|
||||
int num = array_size(ctxs);
|
||||
for (int i = 0; i < num; ++i) {
|
||||
tree->add_cert(ctxs[i], hostnames[i], strlen(hostnames[i]));
|
||||
}
|
||||
|
@ -88,7 +88,7 @@ void test_shrpx_ssl_create_lookup_tree(void) {
|
|||
SSL_CTX_new(SSLv23_method()), SSL_CTX_new(SSLv23_method()),
|
||||
SSL_CTX_new(SSLv23_method()), SSL_CTX_new(SSLv23_method())};
|
||||
const char *names[] = {"rab", "zab", "zzub", "ab"};
|
||||
num = util::array_size(ctxs2);
|
||||
num = array_size(ctxs2);
|
||||
|
||||
tree = make_unique<ssl::CertLookupTree>();
|
||||
for (int i = 0; i < num; ++i) {
|
||||
|
|
|
@ -50,6 +50,10 @@ std::array<T, sizeof...(Rest)+1> make_array(T &&t, Rest &&... rest) {
|
|||
{std::forward<T>(t), std::forward<Rest>(rest)...}};
|
||||
}
|
||||
|
||||
template <typename T, size_t N> constexpr size_t array_size(T (&)[N]) {
|
||||
return N;
|
||||
}
|
||||
|
||||
} // namespace nghttp2
|
||||
|
||||
#endif // TEMPLATE_H
|
||||
|
|
|
@ -54,10 +54,6 @@ namespace nghttp2 {
|
|||
|
||||
namespace util {
|
||||
|
||||
template <typename T, size_t N> constexpr size_t array_size(T (&)[N]) {
|
||||
return N;
|
||||
}
|
||||
|
||||
template <typename T, typename F> struct Defer {
|
||||
Defer(T t, F f) : t(t), f(std::move(f)) {}
|
||||
|
||||
|
|
Loading…
Reference in New Issue