summaryrefslogtreecommitdiff
path: root/utf8.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2018-08-15 22:08:25 (GMT)
committerJunio C Hamano <gitster@pobox.com>2018-08-15 22:08:25 (GMT)
commit7d020f5a78a1ae7ff47d65a2adc79171c0cf9cb7 (patch)
tree5196c1aa277fe6619a24b9f5607f062f20f68b2e /utf8.c
parentbce8031d9a1ff3b791f9e4c1cd1e5634faaf55fb (diff)
parent7726d360b5ba859ae2b6ceefc5d88cc518c78063 (diff)
downloadgit-7d020f5a78a1ae7ff47d65a2adc79171c0cf9cb7.zip
git-7d020f5a78a1ae7ff47d65a2adc79171c0cf9cb7.tar.gz
git-7d020f5a78a1ae7ff47d65a2adc79171c0cf9cb7.tar.bz2
Merge branch 'jk/size-t'
Code clean-up to use size_t/ssize_t when they are the right type. * jk/size-t: strbuf_humanise: use unsigned variables pass st.st_size as hint for strbuf_readlink() strbuf_readlink: use ssize_t strbuf: use size_t for length in intermediate variables reencode_string: use size_t for string lengths reencode_string: use st_add/st_mult helpers
Diffstat (limited to 'utf8.c')
-rw-r--r--utf8.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/utf8.c b/utf8.c
index 982217e..eb78587 100644
--- a/utf8.c
+++ b/utf8.c
@@ -470,14 +470,14 @@ int utf8_fprintf(FILE *stream, const char *format, ...)
#else
typedef char * iconv_ibp;
#endif
-char *reencode_string_iconv(const char *in, size_t insz, iconv_t conv, int *outsz_p)
+char *reencode_string_iconv(const char *in, size_t insz, iconv_t conv, size_t *outsz_p)
{
size_t outsz, outalloc;
char *out, *outpos;
iconv_ibp cp;
outsz = insz;
- outalloc = outsz + 1; /* for terminating NUL */
+ outalloc = st_add(outsz, 1); /* for terminating NUL */
out = xmalloc(outalloc);
outpos = out;
cp = (iconv_ibp)in;
@@ -497,7 +497,7 @@ char *reencode_string_iconv(const char *in, size_t insz, iconv_t conv, int *outs
* converting the rest.
*/
sofar = outpos - out;
- outalloc = sofar + insz * 2 + 32;
+ outalloc = st_add3(sofar, st_mult(insz, 2), 32);
out = xrealloc(out, outalloc);
outpos = out + sofar;
outsz = outalloc - sofar - 1;
@@ -534,9 +534,9 @@ static const char *fallback_encoding(const char *name)
return name;
}
-char *reencode_string_len(const char *in, int insz,
+char *reencode_string_len(const char *in, size_t insz,
const char *out_encoding, const char *in_encoding,
- int *outsz)
+ size_t *outsz)
{
iconv_t conv;
char *out;