This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
perlapi: May want to use savesharedpv on threaded Win32
authorKarl Williamson <public@khwilliamson.com>
Tue, 3 Dec 2013 04:46:37 +0000 (21:46 -0700)
committerKarl Williamson <public@khwilliamson.com>
Tue, 3 Dec 2013 17:05:23 +0000 (10:05 -0700)
Adds a note to savepv (and similar) that on threaded Windows
that you may need to use the saveshared version because the memory is
deallocated when the thread ends.

util.c

diff --git a/util.c b/util.c
index 2b075c9..3bb368f 100644 (file)
--- a/util.c
+++ b/util.c
@@ -896,6 +896,10 @@ string which is a duplicate of C<pv>. The size of the string is
 determined by C<strlen()>. The memory allocated for the new string can
 be freed with the C<Safefree()> function.
 
+On some platforms, Windows for example, all allocated memory owned by a thread
+is deallocated when that thread ends.  So if you need that not to happen, you
+need to use the shared memory functions, such as C<L</savesharedpv>>.
+
 =cut
 */
 
@@ -923,6 +927,10 @@ pointer to a newly allocated string which is a duplicate of the first
 C<len> bytes from C<pv>, plus a trailing NUL byte. The memory allocated for
 the new string can be freed with the C<Safefree()> function.
 
+On some platforms, Windows for example, all allocated memory owned by a thread
+is deallocated when that thread ends.  So if you need that not to happen, you
+need to use the shared memory functions, such as C<L</savesharedpvn>>.
+
 =cut
 */
 
@@ -999,6 +1007,10 @@ Perl_savesharedpvn(pTHX_ const char *const pv, const STRLEN len)
 A version of C<savepv()>/C<savepvn()> which gets the string to duplicate from
 the passed in SV using C<SvPV()>
 
+On some platforms, Windows for example, all allocated memory owned by a thread
+is deallocated when that thread ends.  So if you need that not to happen, you
+need to use the shared memory functions, such as C<L</savesharedsvpv>>.
+
 =cut
 */