Ongoing refactoring (use size_t instead of int)

This commit is contained in:
Mike Gelfand
2015-12-25 10:19:50 +00:00
parent 008730d02c
commit 4a4badd4af
19 changed files with 77 additions and 74 deletions

View File

@@ -43,6 +43,9 @@
#include <stdio.h>
#endif
#include <string.h> /* strlen () */
#include "transmission.h"
#include "ConvertUTF.h"
static const int halfShift = 10; /* used for shifting by 10 bits */
@@ -350,7 +353,7 @@ Boolean isLegalUTF8Sequence (const UTF8 *source, const UTF8 *sourceEnd) {
* In addition to knowing if the sequence is legal, it also tells you the last good character.
*/
Boolean
tr_utf8_validate (const char * str, int max_len, const char ** end)
tr_utf8_validate (const char * str, size_t max_len, const char ** end)
{
const UTF8* source = (const UTF8*) str;
const UTF8* sourceEnd;
@@ -361,7 +364,7 @@ tr_utf8_validate (const char * str, int max_len, const char ** end)
if (str == NULL)
return false;
sourceEnd = source + ((max_len < 0) ? strlen (str) : (size_t)max_len);
sourceEnd = source + (max_len == TR_BAD_SIZE ? strlen (str) : max_len);
if (source == sourceEnd)
{
@@ -390,8 +393,6 @@ tr_utf8_validate (const char * str, int max_len, const char ** end)
return true;
}
}
}