Skip to content

Commit 214f1ae

Browse files
committed
silence warning 'possible loss of data' (win64)
When compiling for 64bit Windows, size_t and unsigned int are of different size, leading cl.exe to warning C4267: conversion from 'size_t' to 'unsigned int', possible loss of data
1 parent 3671d7a commit 214f1ae

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

lodepng.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3046,7 +3046,7 @@ static int color_tree_has(ColorTree* tree, unsigned char r, unsigned char g, uns
30463046
/*color is not allowed to already exist.
30473047
Index should be >= 0 (it's signed to be compatible with using -1 for "doesn't exist")*/
30483048
static void color_tree_add(ColorTree* tree,
3049-
unsigned char r, unsigned char g, unsigned char b, unsigned char a, unsigned index)
3049+
unsigned char r, unsigned char g, unsigned char b, unsigned char a, size_t index)
30503050
{
30513051
int bit;
30523052
for(bit = 0; bit < 8; ++bit)
@@ -4313,7 +4313,7 @@ static unsigned readChunk_tEXt(LodePNGInfo* info, const unsigned char* data, siz
43134313

43144314
while(!error) /*not really a while loop, only used to break on error*/
43154315
{
4316-
unsigned length, string2_begin;
4316+
size_t length, string2_begin;
43174317

43184318
length = 0;
43194319
while(length < chunkLength && data[length] != 0) ++length;
@@ -4354,7 +4354,7 @@ static unsigned readChunk_zTXt(LodePNGInfo* info, const LodePNGDecompressSetting
43544354
unsigned error = 0;
43554355
unsigned i;
43564356

4357-
unsigned length, string2_begin;
4357+
size_t length, string2_begin;
43584358
char *key = 0;
43594359
ucvector decoded;
43604360

@@ -4401,9 +4401,10 @@ static unsigned readChunk_iTXt(LodePNGInfo* info, const LodePNGDecompressSetting
44014401
const unsigned char* data, size_t chunkLength)
44024402
{
44034403
unsigned error = 0;
4404-
unsigned i;
4404+
size_t i;
44054405

4406-
unsigned length, begin, compressed;
4406+
size_t length, begin;
4407+
unsigned compressed;
44074408
char *key = 0, *langtag = 0, *transkey = 0;
44084409
ucvector decoded;
44094410
ucvector_init(&decoded);

0 commit comments

Comments
 (0)