summaryrefslogtreecommitdiffstats
path: root/src/StringUtils.cpp
diff options
context:
space:
mode:
authormadmaxoft <github@xoft.cz>2014-04-04 10:42:17 +0200
committermadmaxoft <github@xoft.cz>2014-04-04 10:42:17 +0200
commite1f75ab6d0862d77bf91b588d54acf63fdf20c63 (patch)
tree1675ed088ad1d43168f3724e864ea4deae5c5287 /src/StringUtils.cpp
parentMore Clang warning fixes in the protocols. (diff)
downloadcuberite-e1f75ab6d0862d77bf91b588d54acf63fdf20c63.tar
cuberite-e1f75ab6d0862d77bf91b588d54acf63fdf20c63.tar.gz
cuberite-e1f75ab6d0862d77bf91b588d54acf63fdf20c63.tar.bz2
cuberite-e1f75ab6d0862d77bf91b588d54acf63fdf20c63.tar.lz
cuberite-e1f75ab6d0862d77bf91b588d54acf63fdf20c63.tar.xz
cuberite-e1f75ab6d0862d77bf91b588d54acf63fdf20c63.tar.zst
cuberite-e1f75ab6d0862d77bf91b588d54acf63fdf20c63.zip
Diffstat (limited to '')
-rw-r--r--src/StringUtils.cpp18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/StringUtils.cpp b/src/StringUtils.cpp
index f46730150..a69d8750f 100644
--- a/src/StringUtils.cpp
+++ b/src/StringUtils.cpp
@@ -531,20 +531,20 @@ AString & UTF8ToRawBEUTF16(const char * a_UTF8, size_t a_UTF8Length, AString & a
format binary data this way:
00001234: 31 32 33 34 35 36 37 38 39 30 61 62 63 64 65 66 1234567890abcdef
*/
-AString & CreateHexDump(AString & a_Out, const void * a_Data, size_t a_Size, int a_LineLength)
+AString & CreateHexDump(AString & a_Out, const void * a_Data, size_t a_Size, size_t a_BytesPerLine)
{
- ASSERT(a_LineLength <= 120); // Due to using a fixed size line buffer; increase line[]'s size to lift this max
+ ASSERT(a_BytesPerLine <= 120); // Due to using a fixed size line buffer; increase line[]'s size to lift this max
char line[512];
char * p;
char * q;
- a_Out.reserve(a_Size / a_LineLength * (18 + 6 * a_LineLength));
- for (int i = 0; i < a_Size; i += a_LineLength)
+ a_Out.reserve(a_Size / a_BytesPerLine * (18 + 6 * a_BytesPerLine));
+ for (size_t i = 0; i < a_Size; i += a_BytesPerLine)
{
- int k = a_Size - i;
- if (k > a_LineLength)
+ size_t k = a_Size - i;
+ if (k > a_BytesPerLine)
{
- k = a_LineLength;
+ k = a_BytesPerLine;
}
#ifdef _MSC_VER
// MSVC provides a "secure" version of sprintf()
@@ -555,8 +555,8 @@ AString & CreateHexDump(AString & a_Out, const void * a_Data, size_t a_Size, int
// Remove the terminating NULL / leftover garbage in line, after the sprintf-ed value
memset(line + Count, 32, sizeof(line) - Count);
p = line + 10;
- q = p + 2 + a_LineLength * 3 + 1;
- for (int j = 0; j < k; j++)
+ q = p + 2 + a_BytesPerLine * 3 + 1;
+ for (size_t j = 0; j < k; j++)
{
unsigned char c = ((unsigned char *)a_Data)[i + j];
p[0] = HEX(c >> 4);