http2: continue using h2o_buffer_reserve
h2o_buffer_try_reserve should only be used for allocations on
unbounded amount of memory. Buffer allocations in H2 connection
so far isn't applicable.
@@ -1051,11 +1051,7 @@ static ssize_t expect_preface(h2o_http2_conn_t *conn, const uint8_t *src, size_t
}
{ /* send SETTINGS and connection-level WINDOW_UPDATE */
- h2o_iovec_t vec = h2o_buffer_try_reserve(&conn->_write.buf, SERVER_PREFACE.len);
- if (vec.base == NULL) {
- *err_desc = "failed to allocate memory";
- return H2O_HTTP2_ERROR_PROTOCOL_CLOSE_IMMEDIATELY;
- }
+ h2o_iovec_t vec = h2o_buffer_reserve(&conn->_write.buf, SERVER_PREFACE.len);
memcpy(vec.base, SERVER_PREFACE.base, SERVER_PREFACE.len);
conn->_write.buf->size += SERVER_PREFACE.len;
if (conn->http2_origin_frame) {
@@ -1148,10 +1144,7 @@ static void on_upgrade_complete(void *_conn, h2o_socket_t *sock, size_t reqsize)
if (conn->_http1_req_input->size > reqsize) {
size_t remaining_bytes = conn->_http1_req_input->size - reqsize;
- if ((h2o_buffer_try_reserve(&sock->input, remaining_bytes)).base == NULL) {
- on_read(conn->sock, "failed to allocate memory");
- return;
- }
+ h2o_buffer_reserve(&sock->input, remaining_bytes);
memcpy(sock->input->bytes, conn->_http1_req_input->bytes + reqsize, remaining_bytes);
sock->input->size += remaining_bytes;
on_read(conn->sock, NULL);
