@@ -181,8 +181,8 @@ void Curl_bufcp_init(struct bufc_pool *pool,
181181 pool -> spare_max = spare_max ;
182182}
183183
184- CURLcode Curl_bufcp_take (struct bufc_pool * pool ,
185- struct buf_chunk * * pchunk )
184+ static CURLcode bufcp_take (struct bufc_pool * pool ,
185+ struct buf_chunk * * pchunk )
186186{
187187 struct buf_chunk * chunk = NULL ;
188188
@@ -205,8 +205,8 @@ CURLcode Curl_bufcp_take(struct bufc_pool *pool,
205205 return CURLE_OK ;
206206}
207207
208- void Curl_bufcp_put (struct bufc_pool * pool ,
209- struct buf_chunk * chunk )
208+ static void bufcp_put (struct bufc_pool * pool ,
209+ struct buf_chunk * chunk )
210210{
211211 if (pool -> spare_count >= pool -> spare_max ) {
212212 free (chunk );
@@ -335,7 +335,7 @@ static struct buf_chunk *get_spare(struct bufq *q)
335335 return NULL ;
336336
337337 if (q -> pool ) {
338- if (Curl_bufcp_take (q -> pool , & chunk ))
338+ if (bufcp_take (q -> pool , & chunk ))
339339 return NULL ;
340340 ++ q -> chunk_count ;
341341 return chunk ;
@@ -360,7 +360,7 @@ static void prune_head(struct bufq *q)
360360 if (q -> tail == chunk )
361361 q -> tail = q -> head ;
362362 if (q -> pool ) {
363- Curl_bufcp_put (q -> pool , chunk );
363+ bufcp_put (q -> pool , chunk );
364364 -- q -> chunk_count ;
365365 }
366366 else if ((q -> chunk_count > q -> max_chunks ) ||
@@ -605,9 +605,18 @@ ssize_t Curl_bufq_sipn(struct bufq *q, size_t max_len,
605605 return nread ;
606606}
607607
608- ssize_t Curl_bufq_slurpn (struct bufq * q , size_t max_len ,
609- Curl_bufq_reader * reader , void * reader_ctx ,
610- CURLcode * err )
608+ /**
609+ * Read up to `max_len` bytes and append it to the end of the buffer queue.
610+ * if `max_len` is 0, no limit is imposed and the call behaves exactly
611+ * the same as `Curl_bufq_slurp()`.
612+ * Returns the total amount of buf read (may be 0) or -1 on other
613+ * reader errors.
614+ * Note that even in case of a -1 chunks may have been read and
615+ * the buffer queue will have different length than before.
616+ */
617+ static ssize_t bufq_slurpn (struct bufq * q , size_t max_len ,
618+ Curl_bufq_reader * reader , void * reader_ctx ,
619+ CURLcode * err )
611620{
612621 ssize_t nread = 0 , n ;
613622
@@ -646,6 +655,5 @@ ssize_t Curl_bufq_slurpn(struct bufq *q, size_t max_len,
646655ssize_t Curl_bufq_slurp (struct bufq * q , Curl_bufq_reader * reader ,
647656 void * reader_ctx , CURLcode * err )
648657{
649- return Curl_bufq_slurpn (q , 0 , reader , reader_ctx , err );
658+ return bufq_slurpn (q , 0 , reader , reader_ctx , err );
650659}
651-
0 commit comments