perlapi: Give more accurate value for needed free space
authorKarl Williamson <khw@cpan.org>
Mon, 12 May 2014 18:42:33 +0000 (12:42 -0600)
committerKarl Williamson <khw@cpan.org>
Mon, 12 May 2014 19:07:04 +0000 (13:07 -0600)
When converting to UTF-8, one usually doesn't need 14 bytes available
space, which is what previously was claimed  It acutally depends on the
value being converted.  This change gives the precise value.

utf8.c

diff --git a/utf8.c b/utf8.c
index dab5387..0ce3eb2 100644 (file)
--- a/utf8.c
+++ b/utf8.c
@@ -230,9 +230,9 @@ Perl_uvoffuni_to_utf8_flags(pTHX_ U8 *d, UV uv, UV flags)
 =for apidoc uvchr_to_utf8
 
 Adds the UTF-8 representation of the native code point C<uv> to the end
-of the string C<d>; C<d> should have at least C<UTF8_MAXBYTES+1> free
-bytes available.  The return value is the pointer to the byte after the
-end of the new character.  In other words,
+of the string C<d>; C<d> should have at least C<UNISKIP(uv)+1> (up to
+C<UTF8_MAXBYTES+1>) free bytes available.  The return value is the pointer to
+the byte after the end of the new character.  In other words,
 
     d = uvchr_to_utf8(d, uv);
 
@@ -259,9 +259,9 @@ Perl_uvchr_to_utf8(pTHX_ U8 *d, UV uv)
 =for apidoc uvchr_to_utf8_flags
 
 Adds the UTF-8 representation of the native code point C<uv> to the end
-of the string C<d>; C<d> should have at least C<UTF8_MAXBYTES+1> free
-bytes available.  The return value is the pointer to the byte after the
-end of the new character.  In other words,
+of the string C<d>; C<d> should have at least C<UNISKIP(uv)+1> (up to
+C<UTF8_MAXBYTES+1>) free bytes available.  The return value is the pointer to
+the byte after the end of the new character.  In other words,
 
     d = uvchr_to_utf8_flags(d, uv, flags);