src: use unique_ptr for http2_state
PR-URL: https://github.com/nodejs/node/pull/17078 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
This commit is contained in:
parent
d61cd9d4fe
commit
2d50b5e537
@ -341,7 +341,6 @@ inline Environment::~Environment() {
|
|||||||
delete[] heap_statistics_buffer_;
|
delete[] heap_statistics_buffer_;
|
||||||
delete[] heap_space_statistics_buffer_;
|
delete[] heap_space_statistics_buffer_;
|
||||||
delete[] http_parser_buffer_;
|
delete[] http_parser_buffer_;
|
||||||
delete http2_state_;
|
|
||||||
free(performance_state_);
|
free(performance_state_);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -496,12 +495,13 @@ inline void Environment::set_http_parser_buffer(char* buffer) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
inline http2::http2_state* Environment::http2_state() const {
|
inline http2::http2_state* Environment::http2_state() const {
|
||||||
return http2_state_;
|
return http2_state_.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void Environment::set_http2_state(http2::http2_state* buffer) {
|
inline void Environment::set_http2_state(
|
||||||
CHECK_EQ(http2_state_, nullptr); // Should be set only once.
|
std::unique_ptr<http2::http2_state> buffer) {
|
||||||
http2_state_ = buffer;
|
CHECK(!http2_state_); // Should be set only once.
|
||||||
|
http2_state_ = std::move(buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline double* Environment::fs_stats_field_array() const {
|
inline double* Environment::fs_stats_field_array() const {
|
||||||
|
@ -617,7 +617,7 @@ class Environment {
|
|||||||
inline void set_http_parser_buffer(char* buffer);
|
inline void set_http_parser_buffer(char* buffer);
|
||||||
|
|
||||||
inline http2::http2_state* http2_state() const;
|
inline http2::http2_state* http2_state() const;
|
||||||
inline void set_http2_state(http2::http2_state * state);
|
inline void set_http2_state(std::unique_ptr<http2::http2_state> state);
|
||||||
|
|
||||||
inline double* fs_stats_field_array() const;
|
inline double* fs_stats_field_array() const;
|
||||||
inline void set_fs_stats_field_array(double* fields);
|
inline void set_fs_stats_field_array(double* fields);
|
||||||
@ -752,7 +752,7 @@ class Environment {
|
|||||||
double* heap_space_statistics_buffer_ = nullptr;
|
double* heap_space_statistics_buffer_ = nullptr;
|
||||||
|
|
||||||
char* http_parser_buffer_;
|
char* http_parser_buffer_;
|
||||||
http2::http2_state* http2_state_ = nullptr;
|
std::unique_ptr<http2::http2_state> http2_state_;
|
||||||
|
|
||||||
double* fs_stats_field_array_;
|
double* fs_stats_field_array_;
|
||||||
|
|
||||||
|
@ -1211,8 +1211,7 @@ void Initialize(Local<Object> target,
|
|||||||
Isolate* isolate = env->isolate();
|
Isolate* isolate = env->isolate();
|
||||||
HandleScope scope(isolate);
|
HandleScope scope(isolate);
|
||||||
|
|
||||||
http2_state* state = new http2_state(isolate);
|
std::unique_ptr<http2_state> state(new http2_state(isolate));
|
||||||
env->set_http2_state(state);
|
|
||||||
|
|
||||||
#define SET_STATE_TYPEDARRAY(name, field) \
|
#define SET_STATE_TYPEDARRAY(name, field) \
|
||||||
target->Set(context, \
|
target->Set(context, \
|
||||||
@ -1234,6 +1233,8 @@ void Initialize(Local<Object> target,
|
|||||||
"optionsBuffer", state->options_buffer.GetJSArray());
|
"optionsBuffer", state->options_buffer.GetJSArray());
|
||||||
#undef SET_STATE_TYPEDARRAY
|
#undef SET_STATE_TYPEDARRAY
|
||||||
|
|
||||||
|
env->set_http2_state(std::move(state));
|
||||||
|
|
||||||
NODE_DEFINE_CONSTANT(target, PADDING_BUF_FRAME_LENGTH);
|
NODE_DEFINE_CONSTANT(target, PADDING_BUF_FRAME_LENGTH);
|
||||||
NODE_DEFINE_CONSTANT(target, PADDING_BUF_MAX_PAYLOAD_LENGTH);
|
NODE_DEFINE_CONSTANT(target, PADDING_BUF_MAX_PAYLOAD_LENGTH);
|
||||||
NODE_DEFINE_CONSTANT(target, PADDING_BUF_RETURN_VALUE);
|
NODE_DEFINE_CONSTANT(target, PADDING_BUF_RETURN_VALUE);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user