Skip to content
This repository is currently being migrated. It's locked while the migration is in progress.

Commit b6211b4

Browse files
committed
grow buffer on overflow
1 parent 6e0da13 commit b6211b4

File tree

1 file changed

+19
-7
lines changed

1 file changed

+19
-7
lines changed

src/influxdb-cpp-rest/influxdb2_simple_async_api.cpp

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -93,17 +93,29 @@ struct simple_db::impl
9393
{
9494
std::vector<concurrency::streams::istream> streams;
9595
auto c = make_compressor(algorithm::GZIP);
96+
97+
bool done = false;
98+
size_t processed = 0;
99+
size_t csize = 0;
96100
std::vector<uint8_t> pre;
97101
pre.resize(w->size());
98-
size_t used;
99-
bool done = false;
100-
auto got = c->compress(reinterpret_cast<const uint8_t*>(w->data()),
101-
w->size(), pre.data(), pre.size(),
102-
web::http::compression::operation_hint::is_last,
103-
used, done);
102+
while (!done)
103+
{
104+
size_t used = 0;
105+
if (csize == pre.size())
106+
{
107+
pre.resize(csize * 2);
108+
}
109+
auto got = c->compress(
110+
reinterpret_cast<const uint8_t*>(w->data()) + processed,
111+
w->size() - processed, pre.data() + csize, pre.size() - csize,
112+
web::http::compression::operation_hint::is_last, used, done);
113+
csize += got;
114+
processed += used;
115+
}
104116
streams.emplace_back(
105117
concurrency::streams::rawptr_stream<uint8_t>::open_istream(
106-
pre.data(), got));
118+
pre.data(), csize));
107119

108120
for (auto& stream : streams)
109121
{

0 commit comments

Comments
 (0)