summaryrefslogtreecommitdiff
path: root/sv.h
diff options
context:
space:
mode:
authorDaniel Dragan <bulk88@hotmail.com>2015-01-15 22:30:25 -0500
committerTony Cook <tony@develop-help.com>2015-01-19 09:58:20 +1100
commitf2979eac0a03fcba1cd431ef3d46f697176ebcc8 (patch)
tree6e8e925b589ccf786d225dff9473a7726b8013ac /sv.h
parente46968af749b24c57e84d0678343f4d6774acfd3 (diff)
downloadperl-f2979eac0a03fcba1cd431ef3d46f697176ebcc8.tar.gz
improve SvPV_set's docs, it really shouldn't be public API
Someone else in the perl community wrote XS code using SvPV_set instead of sv_setpvn and couldn't figure out why he was getting heap corruption/failed asserts/SEGVs/etc. Improve the docs to basically say never use this.
Diffstat (limited to 'sv.h')
-rw-r--r--sv.h11
1 files changed, 8 insertions, 3 deletions
diff --git a/sv.h b/sv.h
index 303bbfac74..10f9449350 100644
--- a/sv.h
+++ b/sv.h
@@ -801,13 +801,18 @@ C<SvIV_set> instead of the lvalue assignment to C<SvIVX>.
Set the value of the NV pointer in sv to val. See C<SvIV_set>.
=for apidoc Am|void|SvPV_set|SV* sv|char* val
-Set the value of the PV pointer in C<sv> to the C<NUL>-terminated string
-C<val>. See also C<SvIV_set>.
+This is probably not what you want to use, you probably wanted
+L</sv_usepvn_flags> or L</sv_setpvn> or L</sv_setpvs>.
+Set the value of the PV pointer in C<sv> to the Perl allocated
+C<NUL>-terminated string C<val>. See also C<SvIV_set>.
+
+Remember to free the previous PV buffer. There are many things to check.
Beware that the existing pointer may be involved in copy-on-write or other
mischief, so do C<SvOOK_off(sv)> and use C<sv_force_normal> or
C<SvPV_force> (or check the SvIsCOW flag) first to make sure this
-modification is safe.
+modification is safe. Then finally, if it is not a COW, call C<SvPV_free> to
+free the previous PV buffer.
=for apidoc Am|void|SvUV_set|SV* sv|UV val
Set the value of the UV pointer in sv to val. See C<SvIV_set>.