nghttp: Use std::unique_ptr for html_parser

This commit is contained in:
Tatsuhiro Tsujikawa 2017-01-18 00:34:39 +09:00
parent 0f33749790
commit 16206d5f67
2 changed files with 3 additions and 7 deletions

View File

@ -157,7 +157,6 @@ Request::Request(const std::string &uri, const http_parser_url &u,
data_offset(0),
response_len(0),
inflater(nullptr),
html_parser(nullptr),
data_prd(data_prd),
header_buffer_size(0),
stream_id(-1),
@ -168,10 +167,7 @@ Request::Request(const std::string &uri, const http_parser_url &u,
http2::init_hdidx(req_hdidx);
}
Request::~Request() {
nghttp2_gzip_inflate_del(inflater);
delete html_parser;
}
Request::~Request() { nghttp2_gzip_inflate_del(inflater); }
void Request::init_inflater() {
int rv;
@ -228,7 +224,7 @@ void Request::init_html_parser() {
base_uri += util::get_uri_field(uri.c_str(), u, UF_QUERY);
}
html_parser = new HtmlParser(base_uri);
html_parser = make_unique<HtmlParser>(base_uri);
}
int Request::update_html_parser(const uint8_t *data, size_t len, int fin) {

View File

@ -176,7 +176,7 @@ struct Request {
// Number of bytes received from server
int64_t response_len;
nghttp2_gzip *inflater;
HtmlParser *html_parser;
std::unique_ptr<HtmlParser> html_parser;
const nghttp2_data_provider *data_prd;
size_t header_buffer_size;
int32_t stream_id;