diff options
author | Denys Otrishko <shishugi@gmail.com> | 2019-11-18 19:07:33 +0200 |
---|---|---|
committer | Anna Henningsen <anna@addaleax.net> | 2019-11-28 00:47:50 +0100 |
commit | df0f9e47ee96c85c94610a7f1071c97843f5ef9f (patch) | |
tree | a2d7213f644c2de72c0bd961d06562b214781bcc /src/node_http2.h | |
parent | 10f5fa75136b540487730b5c1852ea6ad795bb96 (diff) | |
download | android-node-v8-df0f9e47ee96c85c94610a7f1071c97843f5ef9f.tar.gz android-node-v8-df0f9e47ee96c85c94610a7f1071c97843f5ef9f.tar.bz2 android-node-v8-df0f9e47ee96c85c94610a7f1071c97843f5ef9f.zip |
http2: replace direct array usage with struct for js_fields_
PR-URL: https://github.com/nodejs/node/pull/30534
Fixes: https://github.com/nodejs/node/issues/30505
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: David Carlier <devnexen@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'src/node_http2.h')
-rw-r--r-- | src/node_http2.h | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/src/node_http2.h b/src/node_http2.h index 1444738470..61092b60c0 100644 --- a/src/node_http2.h +++ b/src/node_http2.h @@ -673,15 +673,23 @@ class Http2Stream::Provider::Stream : public Http2Stream::Provider { void* user_data); }; +typedef struct { + uint8_t bitfield; + uint8_t priority_listener_count; + uint8_t frame_error_listener_count; +} SessionJSFields; + // Indices for js_fields_, which serves as a way to communicate data with JS // land fast. In particular, we store information about the number/presence // of certain event listeners in JS, and skip calls from C++ into JS if they // are missing. enum SessionUint8Fields { - kBitfield, // See below - kSessionPriorityListenerCount, - kSessionFrameErrorListenerCount, - kSessionUint8FieldCount + kBitfield = offsetof(SessionJSFields, bitfield), // See below + kSessionPriorityListenerCount = + offsetof(SessionJSFields, priority_listener_count), + kSessionFrameErrorListenerCount = + offsetof(SessionJSFields, frame_error_listener_count), + kSessionUint8FieldCount = sizeof(SessionJSFields) }; enum SessionBitfieldFlags { @@ -968,7 +976,7 @@ class Http2Session : public AsyncWrap, public StreamListener { nghttp2_session* session_; // JS-accessible numeric fields, as indexed by SessionUint8Fields. - uint8_t js_fields_[kSessionUint8FieldCount] = {}; + SessionJSFields js_fields_ = {}; // The session type: client or server nghttp2_session_type session_type_; |