@@ -63,7 +63,7 @@ nostd::shared_ptr<HttpCurlGlobalInitializer> HttpCurlGlobalInitializer::GetInsta
6363#ifdef ENABLE_OTLP_COMPRESSION_PREVIEW
6464// Original source:
6565// https://stackoverflow.com/questions/12398377/is-it-possible-to-have-zlib-read-from-and-write-to-the-same-memory-buffer/12412863#12412863
66- int deflateInPlace (z_stream *strm, unsigned char *buf, uint32_t len, uint32_t *max )
66+ int deflateInPlace (z_stream *strm, unsigned char *buf, uint32_t len, uint32_t *max_len )
6767{
6868 // must be large enough to hold zlib or gzip header (if any) and one more byte -- 11 works for the
6969 // worst case here, but if gzip encoding is used and a deflateSetHeader() call is inserted in this
@@ -75,12 +75,12 @@ int deflateInPlace(z_stream *strm, unsigned char *buf, uint32_t len, uint32_t *m
7575 // chunk of input data in order to make room for output data there
7676 strm->next_in = buf;
7777 strm->avail_in = len;
78- if (*max < len)
78+ if (*max_len < len)
7979 {
80- *max = len;
80+ *max_len = len;
8181 }
8282 strm->next_out = temp.data ();
83- strm->avail_out = (std::min)(static_cast <decltype (z_stream::avail_out)>(temp.size ()), *max );
83+ strm->avail_out = (std::min)(static_cast <decltype (z_stream::avail_out)>(temp.size ()), *max_len );
8484 auto ret = deflate (strm, Z_FINISH);
8585 if (ret == Z_STREAM_ERROR)
8686 {
@@ -90,29 +90,29 @@ int deflateInPlace(z_stream *strm, unsigned char *buf, uint32_t len, uint32_t *m
9090 // if we can, copy the temporary output data to the consumed portion of the input buffer, and then
9191 // continue to write up to the start of the consumed input for as long as possible
9292 auto have = strm->next_out - temp.data (); // number of bytes in temp[]
93- if (have <= static_cast <decltype (have)>(strm->avail_in ? len - strm->avail_in : *max ))
93+ if (have <= static_cast <decltype (have)>(strm->avail_in ? len - strm->avail_in : *max_len ))
9494 {
9595 std::memcpy (buf, temp.data (), have);
9696 strm->next_out = buf + have;
9797 have = 0 ;
9898 while (ret == Z_OK)
9999 {
100100 strm->avail_out =
101- strm->avail_in ? strm->next_in - strm->next_out : (buf + *max ) - strm->next_out ;
101+ strm->avail_in ? strm->next_in - strm->next_out : (buf + *max_len ) - strm->next_out ;
102102 ret = deflate (strm, Z_FINISH);
103103 }
104104 if (ret != Z_BUF_ERROR || strm->avail_in == 0 )
105105 {
106- *max = strm->next_out - buf;
106+ *max_len = strm->next_out - buf;
107107 return ret == Z_STREAM_END ? Z_OK : ret;
108108 }
109109 }
110110
111111 // the output caught up with the input due to insufficiently compressible data -- copy the
112112 // remaining input data into an allocated buffer and complete the compression from there to the
113113 // now empty input buffer (this will only occur for long incompressible streams, more than ~20 MB
114- // for the default deflate memLevel of 8, or when *max is too small and less than the length of
115- // the header plus one byte)
114+ // for the default deflate memLevel of 8, or when *max_len is too small and less than the length
115+ // of the header plus one byte)
116116 auto hold = static_cast <std::remove_const_t <decltype (z_stream::next_in)>>(
117117 strm->zalloc (strm->opaque , strm->avail_in , 1 )); // allocated buffer to hold input data
118118 if (hold == Z_NULL)
@@ -126,10 +126,10 @@ int deflateInPlace(z_stream *strm, unsigned char *buf, uint32_t len, uint32_t *m
126126 std::memcpy (buf, temp.data (), have);
127127 strm->next_out = buf + have;
128128 }
129- strm->avail_out = (buf + *max ) - strm->next_out ;
129+ strm->avail_out = (buf + *max_len ) - strm->next_out ;
130130 ret = deflate (strm, Z_FINISH);
131131 strm->zfree (strm->opaque , hold);
132- *max = strm->next_out - buf;
132+ *max_len = strm->next_out - buf;
133133 return ret == Z_OK ? Z_BUF_ERROR : (ret == Z_STREAM_END ? Z_OK : ret);
134134}
135135#endif // ENABLE_OTLP_COMPRESSION_PREVIEW
@@ -167,14 +167,14 @@ void Session::SendRequest(
167167
168168 if (stream == Z_OK)
169169 {
170- auto size = static_cast <uInt>(http_request_->body_ .size ());
171- auto max = size;
172- stream = deflateInPlace (&zs, http_request_->body_ .data (), size, &max );
170+ auto size = static_cast <uInt>(http_request_->body_ .size ());
171+ auto max_size = size;
172+ stream = deflateInPlace (&zs, http_request_->body_ .data (), size, &max_size );
173173
174174 if (stream == Z_OK)
175175 {
176176 http_request_->AddHeader (" Content-Encoding" , " gzip" );
177- http_request_->body_ .resize (max );
177+ http_request_->body_ .resize (max_size );
178178 }
179179 }
180180
0 commit comments