@@ -89,43 +89,6 @@ static bool s_scan_for_crlf(struct aws_h1_decoder *decoder, struct aws_byte_curs
8989 return false;
9090}
9191
92- static int s_cat (struct aws_h1_decoder * decoder , struct aws_byte_cursor to_append ) {
93- struct aws_byte_buf * buffer = & decoder -> scratch_space ;
94- int op = AWS_OP_ERR ;
95- if (buffer -> buffer != NULL ) {
96- if ((aws_byte_buf_append (buffer , & to_append ) == AWS_OP_SUCCESS )) {
97- op = AWS_OP_SUCCESS ;
98- }
99- }
100-
101- if (op != AWS_OP_SUCCESS ) {
102- size_t new_size = buffer -> capacity ? buffer -> capacity : 128 ;
103- do {
104- new_size <<= 1 ; /* new_size *= 2 */
105- if (new_size == 0 ) { /* check for overflow */
106- return aws_raise_error (AWS_ERROR_OOM );
107- }
108- } while (new_size < (buffer -> len + to_append .len ));
109-
110- uint8_t * new_data = aws_mem_acquire (buffer -> allocator , new_size );
111- if (!new_data ) {
112- return AWS_OP_ERR ;
113- }
114-
115- if (buffer -> buffer != NULL ) {
116- memcpy (new_data , buffer -> buffer , buffer -> len );
117- }
118-
119- aws_mem_release (buffer -> allocator , buffer -> buffer );
120- buffer -> capacity = new_size ;
121- buffer -> buffer = new_data ;
122-
123- return aws_byte_buf_append (buffer , & to_append );
124- }
125-
126- return op ;
127- }
128-
12992/* This state consumes an entire line, then calls a linestate_fn to process the line. */
13093static int s_state_getline (struct aws_h1_decoder * decoder , struct aws_byte_cursor * input ) {
13194 /* If preceding runs of this state failed to find CRLF, their data is stored in the scratch_space
@@ -140,8 +103,7 @@ static int s_state_getline(struct aws_h1_decoder *decoder, struct aws_byte_curso
140103
141104 bool use_scratch = !found_crlf | has_prev_data ;
142105 if (AWS_UNLIKELY (use_scratch )) {
143- int err = s_cat (decoder , line );
144- if (err ) {
106+ if (aws_byte_buf_append_dynamic (& decoder -> scratch_space , & line )) {
145107 AWS_LOGF_ERROR (
146108 AWS_LS_HTTP_STREAM ,
147109 "id=%p: Internal buffer write failed with error code %d (%s)" ,
0 commit comments