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 @@ -341,7 +341,6 @@ inline Environment::~Environment() {
341
341
delete[] heap_statistics_buffer_;
342
342
delete[] heap_space_statistics_buffer_;
343
343
delete[] http_parser_buffer_;
344
- delete http2_state_;
345
344
free (performance_state_);
346
345
}
347
346
@@ -496,12 +495,13 @@ inline void Environment::set_http_parser_buffer(char* buffer) {
496
495
}
497
496
498
497
inline http2::http2_state* Environment::http2_state () const {
499
- return http2_state_;
498
+ return http2_state_. get () ;
500
499
}
501
500
502
- inline void Environment::set_http2_state (http2::http2_state* buffer) {
503
- CHECK_EQ (http2_state_, nullptr ); // Should be set only once.
504
- http2_state_ = buffer;
501
+ inline void Environment::set_http2_state (
502
+ std::unique_ptr<http2::http2_state> buffer) {
503
+ CHECK (!http2_state_); // Should be set only once.
504
+ http2_state_ = std::move (buffer);
505
505
}
506
506
507
507
inline double * Environment::fs_stats_field_array () const {
Original file line number Diff line number Diff line change @@ -617,7 +617,7 @@ class Environment {
617
617
inline void set_http_parser_buffer (char * buffer);
618
618
619
619
inline http2::http2_state* http2_state () const ;
620
- inline void set_http2_state (http2::http2_state * state);
620
+ inline void set_http2_state (std::unique_ptr< http2::http2_state> state);
621
621
622
622
inline double * fs_stats_field_array () const ;
623
623
inline void set_fs_stats_field_array (double * fields);
@@ -752,7 +752,7 @@ class Environment {
752
752
double * heap_space_statistics_buffer_ = nullptr ;
753
753
754
754
char * http_parser_buffer_;
755
- http2::http2_state* http2_state_ = nullptr ;
755
+ std::unique_ptr< http2::http2_state> http2_state_;
756
756
757
757
double * fs_stats_field_array_;
758
758
Original file line number Diff line number Diff line change @@ -1211,8 +1211,7 @@ void Initialize(Local<Object> target,
1211
1211
Isolate* isolate = env->isolate ();
1212
1212
HandleScope scope (isolate);
1213
1213
1214
- http2_state* state = new http2_state (isolate);
1215
- env->set_http2_state (state);
1214
+ std::unique_ptr<http2_state> state (new http2_state (isolate));
1216
1215
1217
1216
#define SET_STATE_TYPEDARRAY (name, field ) \
1218
1217
target->Set (context, \
@@ -1234,6 +1233,8 @@ void Initialize(Local<Object> target,
1234
1233
" optionsBuffer" , state->options_buffer .GetJSArray ());
1235
1234
#undef SET_STATE_TYPEDARRAY
1236
1235
1236
+ env->set_http2_state (std::move (state));
1237
+
1237
1238
NODE_DEFINE_CONSTANT (target, PADDING_BUF_FRAME_LENGTH);
1238
1239
NODE_DEFINE_CONSTANT (target, PADDING_BUF_MAX_PAYLOAD_LENGTH);
1239
1240
NODE_DEFINE_CONSTANT (target, PADDING_BUF_RETURN_VALUE);
You can’t perform that action at this time.
0 commit comments