File tree Expand file tree Collapse file tree 3 files changed +10
-9
lines changed
Expand file tree Collapse file tree 3 files changed +10
-9
lines changed Original file line number Diff line number Diff line change @@ -340,7 +340,6 @@ inline Environment::~Environment(){
340340delete[] heap_statistics_buffer_;
341341delete[] heap_space_statistics_buffer_;
342342delete[] http_parser_buffer_;
343- delete http2_state_;
344343free (performance_state_);
345344}
346345
@@ -495,12 +494,13 @@ inline void Environment::set_http_parser_buffer(char* buffer){
495494}
496495
497496inline http2::http2_state* Environment::http2_state () const {
498- return http2_state_;
497+ return http2_state_. get () ;
499498}
500499
501- inline void Environment::set_http2_state (http2::http2_state* buffer){
502- CHECK_EQ (http2_state_, nullptr ); // Should be set only once.
503- http2_state_ = buffer;
500+ inline void Environment::set_http2_state (
501+ std::unique_ptr<http2::http2_state> buffer){
502+ CHECK (!http2_state_); // Should be set only once.
503+ http2_state_ = std::move (buffer);
504504}
505505
506506inline double * Environment::fs_stats_field_array () const {
Original file line number Diff line number Diff line change @@ -619,7 +619,7 @@ class Environment{
619619inline void set_http_parser_buffer (char * buffer);
620620
621621inline http2::http2_state* http2_state () const ;
622- inline void set_http2_state (http2::http2_state * state);
622+ inline void set_http2_state (std::unique_ptr< http2::http2_state> state);
623623
624624inline double * fs_stats_field_array () const ;
625625inline void set_fs_stats_field_array (double * fields);
@@ -737,7 +737,7 @@ class Environment{
737737double * heap_space_statistics_buffer_ = nullptr ;
738738
739739char * http_parser_buffer_;
740- http2::http2_state* http2_state_ = nullptr ;
740+ std::unique_ptr< http2::http2_state> http2_state_;
741741
742742double * fs_stats_field_array_;
743743
Original file line number Diff line number Diff line change @@ -2069,8 +2069,7 @@ void Initialize(Local<Object> target,
20692069 Isolate* isolate = env->isolate ();
20702070 HandleScope scope (isolate);
20712071
2072- http2_state* state = new http2_state (isolate);
2073- env->set_http2_state (state);
2072+ std::unique_ptr<http2_state> state (new http2_state (isolate));
20742073
20752074#define SET_STATE_TYPEDARRAY (name, field ) \
20762075 target->Set (context, \
@@ -2092,6 +2091,8 @@ void Initialize(Local<Object> target,
20922091" optionsBuffer" , state->options_buffer .GetJSArray ());
20932092#undef SET_STATE_TYPEDARRAY
20942093
2094+ env->set_http2_state (std::move (state));
2095+
20952096NODE_DEFINE_CONSTANT (target, PADDING_BUF_FRAME_LENGTH);
20962097NODE_DEFINE_CONSTANT (target, PADDING_BUF_MAX_PAYLOAD_LENGTH);
20972098NODE_DEFINE_CONSTANT (target, PADDING_BUF_RETURN_VALUE);
You can’t perform that action at this time.
0 commit comments