src: Use std::unique_ptr for nv
This commit is contained in:
parent
56f7debad6
commit
776cff3dc7
|
@ -858,7 +858,7 @@ int Http2Upstream::on_downstream_header_complete(Downstream *downstream)
|
||||||
auto end_headers = std::end(downstream->get_response_headers());
|
auto end_headers = std::end(downstream->get_response_headers());
|
||||||
size_t nheader = downstream->get_response_headers().size();
|
size_t nheader = downstream->get_response_headers().size();
|
||||||
// 4 means :status and possible via header field.
|
// 4 means :status and possible via header field.
|
||||||
const char **nv = new const char*[nheader * 2 + 4 + 1];
|
auto nv = util::make_unique<const char*[]>(nheader * 2 + 4 + 1);
|
||||||
size_t hdidx = 0;
|
size_t hdidx = 0;
|
||||||
std::string via_value;
|
std::string via_value;
|
||||||
auto response_status =
|
auto response_status =
|
||||||
|
@ -899,9 +899,8 @@ int Http2Upstream::on_downstream_header_complete(Downstream *downstream)
|
||||||
data_prd.read_callback = spdy_data_read_callback;
|
data_prd.read_callback = spdy_data_read_callback;
|
||||||
|
|
||||||
int rv;
|
int rv;
|
||||||
rv = nghttp2_submit_response(session_, downstream->get_stream_id(), nv,
|
rv = nghttp2_submit_response(session_, downstream->get_stream_id(), nv.get(),
|
||||||
&data_prd);
|
&data_prd);
|
||||||
delete [] nv;
|
|
||||||
if(rv != 0) {
|
if(rv != 0) {
|
||||||
ULOG(FATAL, this) << "nghttp2_submit_response() failed";
|
ULOG(FATAL, this) << "nghttp2_submit_response() failed";
|
||||||
return -1;
|
return -1;
|
||||||
|
|
|
@ -807,7 +807,7 @@ int SpdyUpstream::on_downstream_header_complete(Downstream *downstream)
|
||||||
}
|
}
|
||||||
size_t nheader = downstream->get_response_headers().size();
|
size_t nheader = downstream->get_response_headers().size();
|
||||||
// 6 means :status, :version and possible via header field.
|
// 6 means :status, :version and possible via header field.
|
||||||
const char **nv = new const char*[nheader * 2 + 6 + 1];
|
auto nv = util::make_unique<const char*[]>(nheader * 2 + 6 + 1);
|
||||||
size_t hdidx = 0;
|
size_t hdidx = 0;
|
||||||
std::string via_value;
|
std::string via_value;
|
||||||
nv[hdidx++] = ":status";
|
nv[hdidx++] = ":status";
|
||||||
|
@ -854,9 +854,8 @@ int SpdyUpstream::on_downstream_header_complete(Downstream *downstream)
|
||||||
data_prd.read_callback = spdy_data_read_callback;
|
data_prd.read_callback = spdy_data_read_callback;
|
||||||
|
|
||||||
int rv;
|
int rv;
|
||||||
rv = spdylay_submit_response(session_, downstream->get_stream_id(), nv,
|
rv = spdylay_submit_response(session_, downstream->get_stream_id(), nv.get(),
|
||||||
&data_prd);
|
&data_prd);
|
||||||
delete [] nv;
|
|
||||||
if(rv != 0) {
|
if(rv != 0) {
|
||||||
ULOG(FATAL, this) << "spdylay_submit_response() failed";
|
ULOG(FATAL, this) << "spdylay_submit_response() failed";
|
||||||
return -1;
|
return -1;
|
||||||
|
|
Loading…
Reference in New Issue