The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

Implements "ENTER" in perlapi

Implements "LEAVE" in perlapi

A helper function for localizing the SV referenced by *sptr.

If SAVEf_KEEPOLDELEM is set in in flags, the function returns the input scalar untouched.

Otherwise it replaces *sptr with a new undef scalar, and returns that. The new scalar will have the old one's magic (if any) copied to it. If there is such magic, and SAVEf_SETMAGIC is set in in flags, 'set' magic will be processed on the new scalar. If unset, 'set' magic will be skipped. The latter typically means that assignment will soon follow (e.g., 'local $x = $y'), and that will handle the magic.

Implements SAVEGENERICSV.

Like save_sptr(), but also SvREFCNT_dec()s the new value. Can be used to restore a global SV to its prior contents, freeing new value.

Implements SAVERCPV.

Saves and restores a refcounted string, similar to what save_generic_svref would do for a SV*. Can be used to restore a refcounted string to its previous state. Performs the appropriate refcount counting so that nothing should leak or be prematurely freed.

Implements SAVEFREERCPV.

Saves and frees a refcounted string. Calls rcpv_free() on the argument when the current pseudo block is finished.

Implements SAVEGENERICPV.

Like save_pptr(), but also Safefree()s the new value if it is different from the old one. Can be used to restore a global char* to its prior contents, freeing new value.

Implements SAVESHAREDPV.

Like save_generic_pvref(), but uses PerlMemShared_free() rather than Safefree(). Can be used to restore a shared global char* to its prior contents, freeing new value.

Implements SAVESETSVFLAGS.

Set the SvFLAGS specified by mask to the values in val

Saves the current GP of gv on the save stack to be restored on scope exit.

If empty is true, replace the GP with a new GP.

If empty is false, mark gv with GVf_INTRO so the next reference assigned is localized, which is how local *foo = $someref; works.

Implements SAVEVPTR.

Implements SAVEPADSVANDMORTALIZE.

The refcnt of object ptr will be decremented at the end of the current pseudo-block. type gives the type of ptr, expressed as one of the constants in scope.h whose name begins with SAVEt_.

This is the underlying implementation of several macros, like SAVEFREESV.

Implements SAVEHDELETE.

Implements SAVEADELETE.

Implements SAVEHINTS.

These each arrange for the value of the array element av[idx] to be restored at the end of the enclosing pseudo-block.

In save_aelem, the SV at C**sptr> will be replaced by a new undef scalar. That scalar will inherit any magic from the original **sptr, and any 'set' magic will be processed.

In save_aelem_flags, SAVEf_KEEPOLDELEM being set in flags causes the function to forgo all that: the scalar at **sptr is untouched. If SAVEf_KEEPOLDELEM is not set, the SV at C**sptr> will be replaced by a new undef scalar. That scalar will inherit any magic from the original **sptr. Any 'set' magic will be processed if and only if SAVEf_SETMAGIC is set in in flags.

These each arrange for the value of the hash element (in Perlish terms) $hv{key}] to be restored at the end of the enclosing pseudo-block.

In save_helem, the SV at C**sptr> will be replaced by a new undef scalar. That scalar will inherit any magic from the original **sptr, and any 'set' magic will be processed.

In save_helem_flags, SAVEf_KEEPOLDELEM being set in flags causes the function to forgo all that: the scalar at **sptr is untouched. If SAVEf_KEEPOLDELEM is not set, the SV at C**sptr> will be replaced by a new undef scalar. That scalar will inherit any magic from the original **sptr. Any 'set' magic will be processed if and only if SAVEf_SETMAGIC is set in in flags.

Implements "SSNEW" in perlapi and kin, which should be used instead of this function.

Implements LEAVE_SCOPE which you should use instead.

This function arranges for either a Perl code reference, or a C function reference to be called at the end of the current statement.

The coderef argument determines the type of function that will be called. If it is SvROK() it is assumed to be a reference to a CV and will arrange for the coderef to be called. If it is not SvROK() then it is assumed to be a SvIV() which is SvIOK() whose value is a pointer to a C function of type DESTRUCTORFUNC_t created using PTR2INT(). Either way the args parameter will be provided to the callback as a parameter, although the rules for doing so differ between the Perl and C mode. Normally this function is only used directly for the Perl case and the wrapper mortal_destructor_x() is used for the C function case.

When operating in Perl callback mode the args parameter may be NULL in which case the code reference is called with no arguments, otherwise if it is an AV (SvTYPE(args) == SVt_PVAV) then the contents of the AV will be used as the arguments to the code reference, and if it is any other type then the args SV will be provided as a single argument to the code reference.

When operating in a C callback mode the args parameter will be passed directly to the C function as a void * pointer. No additional processing of the argument will be peformed, and it is the callers responsibility to free the args parameter if necessary.

Be aware that there is a signficant difference in timing between the end of the current statement and the end of the current pseudo block. If you are looking for a mechanism to trigger a function at the end of the current pseudo block you should look at SAVEDESTRUCTORX() instead of this function.

This function arranges for a C function reference to be called at the end of the current statement with the arguments provided. It is a wrapper around mortal_destructor_sv() which ensures that the latter function is called appropriately.

Be aware that there is a signficant difference in timing between the end of the current statement and the end of the current pseudo block. If you are looking for a mechanism to trigger a function at the end of the current pseudo block you should look at SAVEDESTRUCTORX() instead of this function.

This function is called via magic to implement the mortal_destructor_sv() and mortal_destructor_x() functions. It should not be called directly and has no user servicable parts.