summaryrefslogtreecommitdiffstats
path: root/src/StringCompression.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/StringCompression.cpp')
-rw-r--r--src/StringCompression.cpp32
1 files changed, 16 insertions, 16 deletions
diff --git a/src/StringCompression.cpp b/src/StringCompression.cpp
index af9f1687f..dd22dd4d4 100644
--- a/src/StringCompression.cpp
+++ b/src/StringCompression.cpp
@@ -13,13 +13,13 @@
/// Compresses a_Data into a_Compressed; returns Z_XXX error constants same as zlib's compress2()
int CompressString(const char * a_Data, size_t a_Length, AString & a_Compressed, int a_Factor)
{
- uLongf CompressedSize = compressBound((uLong)a_Length);
+ uLongf CompressedSize = compressBound(static_cast<uLong>(a_Length));
// HACK: We're assuming that AString returns its internal buffer in its data() call and we're overwriting that buffer!
// It saves us one allocation and one memcpy of the entire compressed data
// It may not work on some STL implementations! (Confirmed working on MSVC 2008 & 2010)
a_Compressed.resize(CompressedSize);
- int errorcode = compress2((Bytef*)a_Compressed.data(), &CompressedSize, (const Bytef *)a_Data, (uLong)a_Length, a_Factor);
+ int errorcode = compress2(reinterpret_cast<Bytef *>(const_cast<char *>(a_Compressed.data())), &CompressedSize, reinterpret_cast<const Bytef *>(a_Data), static_cast<uLong>(a_Length), a_Factor);
if (errorcode != Z_OK)
{
return errorcode;
@@ -39,8 +39,8 @@ int UncompressString(const char * a_Data, size_t a_Length, AString & a_Uncompres
// It saves us one allocation and one memcpy of the entire compressed data
// It may not work on some STL implementations! (Confirmed working on MSVC 2008 & 2010)
a_Uncompressed.resize(a_UncompressedSize);
- uLongf UncompressedSize = (uLongf)a_UncompressedSize; // On some architectures the uLongf is different in size to int, that may be the cause of the -5 error
- int errorcode = uncompress((Bytef*)a_Uncompressed.data(), &UncompressedSize, (const Bytef*)a_Data, (uLong)a_Length);
+ uLongf UncompressedSize = static_cast<uLongf>(a_UncompressedSize); // On some architectures the uLongf is different in size to int, that may be the cause of the -5 error
+ int errorcode = uncompress(reinterpret_cast<Bytef *>(const_cast<char *>(a_Uncompressed.data())), &UncompressedSize, reinterpret_cast<const Bytef *>(a_Data), static_cast<uLong>(a_Length));
if (errorcode != Z_OK)
{
return errorcode;
@@ -62,9 +62,9 @@ int CompressStringGZIP(const char * a_Data, size_t a_Length, AString & a_Compres
char Buffer[64 KiB];
z_stream strm;
memset(&strm, 0, sizeof(strm));
- strm.next_in = (Bytef *)a_Data;
- strm.avail_in = (uInt)a_Length;
- strm.next_out = (Bytef *)Buffer;
+ strm.next_in = reinterpret_cast<Bytef *>(const_cast<char *>(a_Data));
+ strm.avail_in = static_cast<uInt>(a_Length);
+ strm.next_out = reinterpret_cast<Bytef *>(Buffer);
strm.avail_out = sizeof(Buffer);
int res = deflateInit2(&strm, 9, Z_DEFLATED, 31, 9, Z_DEFAULT_STRATEGY);
@@ -83,7 +83,7 @@ int CompressStringGZIP(const char * a_Data, size_t a_Length, AString & a_Compres
{
// Some data has been compressed. Consume the buffer and continue compressing
a_Compressed.append(Buffer, sizeof(Buffer) - strm.avail_out);
- strm.next_out = (Bytef *)Buffer;
+ strm.next_out = reinterpret_cast<Bytef *>(Buffer);
strm.avail_out = sizeof(Buffer);
if (strm.avail_in == 0)
{
@@ -126,9 +126,9 @@ extern int UncompressStringGZIP(const char * a_Data, size_t a_Length, AString &
char Buffer[64 KiB];
z_stream strm;
memset(&strm, 0, sizeof(strm));
- strm.next_in = (Bytef *)a_Data;
- strm.avail_in = (uInt)a_Length;
- strm.next_out = (Bytef *)Buffer;
+ strm.next_in = reinterpret_cast<Bytef *>(const_cast<char *>(a_Data));
+ strm.avail_in = static_cast<uInt>(a_Length);
+ strm.next_out = reinterpret_cast<Bytef *>(Buffer);
strm.avail_out = sizeof(Buffer);
int res = inflateInit2(&strm, 31); // Force GZIP decoding
@@ -147,7 +147,7 @@ extern int UncompressStringGZIP(const char * a_Data, size_t a_Length, AString &
{
// Some data has been uncompressed. Consume the buffer and continue uncompressing
a_Uncompressed.append(Buffer, sizeof(Buffer) - strm.avail_out);
- strm.next_out = (Bytef *)Buffer;
+ strm.next_out = reinterpret_cast<Bytef *>(Buffer);
strm.avail_out = sizeof(Buffer);
if (strm.avail_in == 0)
{
@@ -188,9 +188,9 @@ extern int InflateString(const char * a_Data, size_t a_Length, AString & a_Uncom
char Buffer[64 KiB];
z_stream strm;
memset(&strm, 0, sizeof(strm));
- strm.next_in = (Bytef *)a_Data;
- strm.avail_in = (uInt)a_Length;
- strm.next_out = (Bytef *)Buffer;
+ strm.next_in = reinterpret_cast<Bytef *>(const_cast<char *>(a_Data));
+ strm.avail_in = static_cast<uInt>(a_Length);
+ strm.next_out = reinterpret_cast<Bytef *>(Buffer);
strm.avail_out = sizeof(Buffer);
int res = inflateInit(&strm); // Force GZIP decoding
@@ -209,7 +209,7 @@ extern int InflateString(const char * a_Data, size_t a_Length, AString & a_Uncom
{
// Some data has been uncompressed. Consume the buffer and continue uncompressing
a_Uncompressed.append(Buffer, sizeof(Buffer) - strm.avail_out);
- strm.next_out = (Bytef *)Buffer;
+ strm.next_out = reinterpret_cast<Bytef *>(Buffer);
strm.avail_out = sizeof(Buffer);
if (strm.avail_in == 0)
{