| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -340,7 +340,6 @@ inline Environment::~Environment() { | |||
| 340 | 340 | delete[] heap_statistics_buffer_; | |
| 341 | 341 | delete[] heap_space_statistics_buffer_; | |
| 342 | 342 | delete[] http_parser_buffer_; | |
| 343 | - delete http2_state_; | ||
| 344 | 343 | free(performance_state_); | |
| 345 | 344 | } | |
| 346 | 345 | ||
@@ -495,12 +494,13 @@ inline void Environment::set_http_parser_buffer(char* buffer) { | |||
| 495 | 494 | } | |
| 496 | 495 | ||
| 497 | 496 | inline http2::http2_state* Environment::http2_state() const { | |
| 498 | - return http2_state_; | ||
| 497 | + return http2_state_.get(); | ||
| 499 | 498 | } | |
| 500 | 499 | ||
| 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); | ||
| 504 | 504 | } | |
| 505 | 505 | ||
| 506 | 506 | inline double* Environment::fs_stats_field_array() const { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -619,7 +619,7 @@ class Environment { | |||
| 619 | 619 | inline void set_http_parser_buffer(char* buffer); | |
| 620 | 620 | ||
| 621 | 621 | inline 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); | ||
| 623 | 623 | ||
| 624 | 624 | inline double* fs_stats_field_array() const; | |
| 625 | 625 | inline void set_fs_stats_field_array(double* fields); | |
@@ -737,7 +737,7 @@ class Environment { | |||
| 737 | 737 | double* heap_space_statistics_buffer_ = nullptr; | |
| 738 | 738 | ||
| 739 | 739 | char* http_parser_buffer_; | |
| 740 | - http2::http2_state* http2_state_ = nullptr; | ||
| 740 | + std::unique_ptr<http2::http2_state> http2_state_; | ||
| 741 | 741 | ||
| 742 | 742 | double* fs_stats_field_array_; | |
| 743 | 743 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2069,8 +2069,7 @@ void Initialize(Local<Object> target, | |||
| 2069 | 2069 | Isolate* isolate = env->isolate(); | |
| 2070 | 2070 | HandleScope scope(isolate); | |
| 2071 | 2071 | ||
| 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)); | ||
| 2074 | 2073 | ||
| 2075 | 2074 | #define SET_STATE_TYPEDARRAY(name, field) \ | |
| 2076 | 2075 | target->Set(context, \ | |
@@ -2092,6 +2091,8 @@ void Initialize(Local<Object> target, | |||
| 2092 | 2091 | "optionsBuffer", state->options_buffer.GetJSArray()); | |
| 2093 | 2092 | #undef SET_STATE_TYPEDARRAY | |
| 2094 | 2093 | ||
| 2094 | + env->set_http2_state(std::move(state)); | ||
| 2095 | + | ||
| 2095 | 2096 | NODE_DEFINE_CONSTANT(target, PADDING_BUF_FRAME_LENGTH); | |
| 2096 | 2097 | NODE_DEFINE_CONSTANT(target, PADDING_BUF_MAX_PAYLOAD_LENGTH); | |
| 2097 | 2098 | NODE_DEFINE_CONSTANT(target, PADDING_BUF_RETURN_VALUE); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments