Skip to content

Commit 83b32ab

Browse files
committed
Improve documentation of sv_dup and sv_dup_inc
1 parent 166fcd9 commit 83b32ab

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

sv.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14974,18 +14974,18 @@ S_sv_dup_common(pTHX_ const SV *const ssv, CLONE_PARAMS *const param)
1497414974

1497514975
In spite of their generic names, these are very specialized functions mainly
1497614976
for use when cloning an interpreter instance. You are probably looking for
14977-
L<perlapi/newSVsv>.
14977+
L<perlapi/newSVsv>. Generally speaking you will only want to use these in
14978+
either a C<svt_dup> magic handler, or a C<CLONE> method.
1497814979

1497914980
They duplicate an SV of any type (not just a plain SV, but including AV, HV
14980-
I<etc>.), returning a pointer to the cloned object. The difference is that the
14981-
new SV under C<sv_dup> has a reference count of 0, but 1 under C<sv_dup_inc>.
14982-
Only specialized cases will want a zero reference count, almost certainly only
14983-
when you aren't already holding a reference. Thus, you almost always want to
14984-
use the C<sv_dup_inc> form.
14985-
14986-
The cloning process uses a cache, so that if a particular SV address has
14987-
already been duped, that duped SV is returned again rather than creating a
14988-
second duplicate.
14981+
I<etc>.), returning a pointer to the cloned object. The cloning process uses a
14982+
lookup table, so that if a particular source SV address has already been duped,
14983+
that duped SV is returned rather than creating a second duplicate.
14984+
14985+
The difference is that the new SV under C<sv_dup> will not have its reference count incremented
14986+
(potentially causing it to be zero), unlike under C<sv_dup_inc>. This is only
14987+
desirable when cloning a non-owning pointer. Thus, you almost always want to use
14988+
the C<sv_dup_inc> form.
1498914989

1499014990
C<param> has type S<C<CLONE_PARAMS *>>. This is mostly for internal core use
1499114991
when duplicating something more complicated than an SV (code in common is

0 commit comments

Comments
 (0)