reencode_string: use size_t for string lengths

The iconv interface takes a size_t, which is the appropriate
type for an in-memory buffer. But our reencode_string_*
functions use integers, meaning we may get confusing results
when the sizes exceed INT_MAX. Let's use size_t
consistently.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Jeff King
2018-07-24 06:50:33 -04:00
committed by Junio C Hamano
parent 77aa03d6c7
commit c7d017d7e1
5 changed files with 13 additions and 13 deletions

10
utf8.h
View File

@ -25,14 +25,14 @@ void strbuf_utf8_replace(struct strbuf *sb, int pos, int width,
#ifndef NO_ICONV
char *reencode_string_iconv(const char *in, size_t insz,
iconv_t conv, int *outsz);
char *reencode_string_len(const char *in, int insz,
iconv_t conv, size_t *outsz);
char *reencode_string_len(const char *in, size_t insz,
const char *out_encoding,
const char *in_encoding,
int *outsz);
size_t *outsz);
#else
static inline char *reencode_string_len(const char *a, int b,
const char *c, const char *d, int *e)
static inline char *reencode_string_len(const char *a, size_t b,
const char *c, const char *d, size_t *e)
{ if (e) *e = 0; return NULL; }
#endif