Mercurial > hg > th-libs
changeset 540:a3e3b26accd5
Add comment about minimum buffer size requirement.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Mon, 30 Dec 2019 15:18:55 +0200 |
parents | 7615dbdc4d34 |
children | a5fb0d95a51f |
files | th_printf1.c |
diffstat | 1 files changed, 3 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/th_printf1.c Mon Dec 30 15:16:04 2019 +0200 +++ b/th_printf1.c Mon Dec 30 15:18:55 2019 +0200 @@ -35,14 +35,17 @@ if (val == 0) return 0; + // We assume that the output buffer is at least 2 bytes long *pos = 0; do { TH_PFUNC_TYPE_U digit = val % f_radix; + if (digit < 10) buf[*pos] = '0' + digit; else buf[*pos] = (f_upcase ? 'A' : 'a') + digit - 10; + val /= f_radix; (*pos)++; }