IXHttpClient.cpp: use std::array instead of std::unique_ptr for a fixed size array
This commit is contained in:
parent
3dabd3a556
commit
42f71364ca
@ -16,6 +16,7 @@
|
|||||||
#include <random>
|
#include <random>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <array>
|
||||||
|
|
||||||
#ifdef IXWEBSOCKET_USE_ZLIB
|
#ifdef IXWEBSOCKET_USE_ZLIB
|
||||||
#include <zlib.h>
|
#include <zlib.h>
|
||||||
@ -700,14 +701,12 @@ namespace ix
|
|||||||
inflateState.next_in = (unsigned char*) (const_cast<char*>(in.data()));
|
inflateState.next_in = (unsigned char*) (const_cast<char*>(in.data()));
|
||||||
|
|
||||||
const int kBufferSize = 1 << 14;
|
const int kBufferSize = 1 << 14;
|
||||||
|
std::array<unsigned char, kBufferSize> compressBuffer;
|
||||||
std::unique_ptr<unsigned char[]> compressBuffer =
|
|
||||||
std::make_unique<unsigned char[]>(kBufferSize);
|
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
inflateState.avail_out = (uInt) kBufferSize;
|
inflateState.avail_out = (uInt) kBufferSize;
|
||||||
inflateState.next_out = compressBuffer.get();
|
inflateState.next_out = &compressBuffer.front();
|
||||||
|
|
||||||
int ret = inflate(&inflateState, Z_SYNC_FLUSH);
|
int ret = inflate(&inflateState, Z_SYNC_FLUSH);
|
||||||
|
|
||||||
@ -717,7 +716,7 @@ namespace ix
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
out.append(reinterpret_cast<char*>(compressBuffer.get()),
|
out.append(reinterpret_cast<char*>(&compressBuffer.front()),
|
||||||
kBufferSize - inflateState.avail_out);
|
kBufferSize - inflateState.avail_out);
|
||||||
} while (inflateState.avail_out == 0);
|
} while (inflateState.avail_out == 0);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user