Skip to content

Commit 2285165

Browse files
committed
perlapi: Document sv_dup(_inc)?
1 parent 69b5e8a commit 2285165

File tree

2 files changed

+31
-2
lines changed

2 files changed

+31
-2
lines changed

embed.fnc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6360,9 +6360,9 @@ CRdp |PERL_SI *|si_dup |NULLOK PERL_SI *si \
63606360
|NN CLONE_PARAMS *param
63616361
CRdp |ANY * |ss_dup |NN PerlInterpreter *proto_perl \
63626362
|NN CLONE_PARAMS *param
6363-
ARp |SV * |sv_dup |NULLOK const SV * const ssv \
6363+
CRdp |SV * |sv_dup |NULLOK const SV * const ssv \
63646364
|NN CLONE_PARAMS * const param
6365-
ARp |SV * |sv_dup_inc |NULLOK const SV * const ssv \
6365+
CRdp |SV * |sv_dup_inc |NULLOK const SV * const ssv \
63666366
|NN CLONE_PARAMS * const param
63676367
# if defined(PERL_IN_OP_C) || defined(PERL_IN_PEEP_C)
63686368
p |void |op_relocate_sv |NN SV **svp \

sv.c

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15054,6 +15054,35 @@ S_sv_dup_common(pTHX_ const SV *const ssv, CLONE_PARAMS *const param)
1505415054
return dsv;
1505515055
}
1505615056

15057+
/*
15058+
=for apidoc sv_dup
15059+
=for apidoc_item sv_dup_inc
15060+
15061+
In spite of their generic names, these are very specialized functions mainly
15062+
for use when cloning an interpreter instance. You are probably looking for
15063+
L<perlapi/newSVsv>.
15064+
15065+
They duplicate an SV of any type (not just a plain SV, but including AV, HV
15066+
I<etc>.), returning a pointer to the cloned object. The difference is that the
15067+
new SV under C<sv_dup> has a reference count of 0, but 1 under C<sv_dup_inc>.
15068+
Only specialized cases will want a zero reference count, almost certainly only
15069+
when you aren't already holding a reference. Thus, you almost always want to
15070+
use the C<sv_dup_inc> form.
15071+
15072+
The cloning process uses use a cache, so that if a particular SV address has
15073+
already been duped, that duped SV is returned again rather than creating a
15074+
second duplicate.
15075+
15076+
C<param> has type S<C<CLONE_PARAMS *>>. This is mostly for internal core use
15077+
when duplicating something more complicated than an SV (code in common is
15078+
used). Your code may inherit this parameter, which you merely pass on, but you
15079+
can initialize it by using C<clone_params_new>. Don't forget to
15080+
free it when done, via C<clone_params_del>>. Its only member that is
15081+
public is C<flags>, all which are documented in L<perlapi/perl_clone>.
15082+
15083+
=cut
15084+
*/
15085+
1505715086
SV *
1505815087
Perl_sv_dup_inc(pTHX_ const SV *const ssv, CLONE_PARAMS *const param)
1505915088
{

0 commit comments

Comments
 (0)