call the function C<sv_grow>. Note that C<SvGROW> can only increase, not
decrease, the allocated memory of an SV and that it does not automatically
add a byte for the a trailing NUL (perl's own string functions typically do
-SvGROW(sv, len + 1)).
+C<SvGROW(sv, len + 1)>).
If you have an SV and want to know what kind of data Perl thinks is stored
in it, you can use the following macros to check the type of SV you have.
This returns NULL if the variable does not exist.
-The hash algorithm is defined in the PERL_HASH(hash, key, klen) macro:
+The hash algorithm is defined in the C<PERL_HASH(hash, key, klen)> macro:
i = klen;
hash = 0;
/* Still under construction */
Upgrades rv to reference if not already one. Creates new SV for rv to
-point to.
-If classname is non-null, the SV is blessed into the specified class.
-SV is returned.
+point to. If C<classname> is non-null, the SV is blessed into the specified
+class. SV is returned.
SV* newSVrv(SV* rv, char* classname);
-Copies integer or double into an SV whose reference is rv. SV is blessed
-if classname is non-null.
+Copies integer or double into an SV whose reference is C<rv>. SV is blessed
+if C<classname> is non-null.
SV* sv_setref_iv(SV* rv, char* classname, IV iv);
SV* sv_setref_nv(SV* rv, char* classname, NV iv);
Copies the pointer value (I<the address, not the string!>) into an SV whose
-reference is rv. SV is blessed if classname is non-null.
+reference is rv. SV is blessed if C<classname> is non-null.
SV* sv_setref_pv(SV* rv, char* classname, PV iv);
-Copies string into an SV whose reference is rv.
-Set length to 0 to let Perl calculate the string length.
-SV is blessed if classname is non-null.
+Copies string into an SV whose reference is C<rv>. Set length to 0 to let
+Perl calculate the string length. SV is blessed if C<classname> is non-null.
SV* sv_setref_pvn(SV* rv, char* classname, PV iv, int length);
terminates. This is a memory leak.
The correct procedure, then, is to use C<newRV_noinc> instead of
-C<newRV_inc>. Then, if and when the last reference is destroyed, the
-reference count of the SV will go to zero and it will be destroyed,
+C<newRV_inc>. Then, if and when the last reference is destroyed,
+the reference count of the SV will go to zero and it will be destroyed,
stopping any memory leak.
There are some convenience functions available that can help with the
SV to a mortal SV (and thus defers a call to C<SvREFCNT_dec>), and the
third creates a mortal copy of an existing SV.
-The mortal routines are not just for SV's -- AV's and HV's can be made
-mortal by passing their addresses (type-casted to C<SV*>) to the
+The mortal routines are not just for SV's -- AV's and HV's can be
+made mortal by passing their address (type-casted to C<SV*>) to the
C<sv_2mortal> or C<sv_mortalcopy> routines.
=head2 Stashes and Globs
U vtbl_uvar ???
v vtbl_vec Vector
x vtbl_substr Substring???
- y vtbl_vivary Shadow variable in foreach loop
+ y vtbl_itervar Shadow "foreach" iterator variable
* vtbl_glob GV???
# vtbl_arylen Array Length
. vtbl_pos $. scalar variable
=head2 Scratchpads
-=head3 Putting a C value on Perl stack
+=head2 Putting a C value on Perl stack
A lot of opcodes (this is an elementary operation in the internal perl
stack machine) put an SV* on the stack. However, as an optimization
directly used in some opcodes, as well as indirectly in zillions of
others, which use it via C<(X)PUSH[pni]>.
-=head3 Scratchpads
+=head2 Scratchpads
The question remains on when the SV's which are I<target>s for opcodes
are created. The answer is that they are created when the current unit --
OP's in the compile tree of the unit can use the same target, if this
would not conflict with the expected life of the temporary.
-=head3 Scratchpads and recursions
+=head2 Scratchpads and recursions
In fact it is not 100% true that a compiled unit contains a pointer to
the scratchpad AV. In fact it contains a pointer to an AV of
Used to indicate scalar context. See C<GIMME> and L<perlcall>.
+=item gv_fetchmeth
+
+Returns the glob with the given C<name> and a defined subroutine or
+C<NULL>. The glob lives in the given C<stash>, or in the stashes accessable
+via @ISA and @<UNIVERSAL>.
+
+As a side-effect creates a glob with the given C<name> in the given C<stash>
+which in the case of success contains an alias for the subroutine, and
+sets up caching info for this glob. Similarly for all the searched
+stashes.
+
+ GV* gv_fetchmeth _((HV* stash, char* name, STRLEN len, I32 level));
+
+=item gv_fetchmethod
+
+Returns the glob which contains the subroutine to call to invoke the
+method on the C<stash>. In fact in the presense of autoloading this may
+be the glob for "AUTOLOAD". In this case the corresponing variable
+$AUTOLOAD is already setup.
+
+Note that if you want to keep this glob for a long time, you need to
+check for it being "AUTOLOAD", since at the later time the the call
+may load a different subroutine due to $AUTOLOAD changing its value.
+Use the glob created via a side effect to do this.
+
+This function grants C<"SUPER"> token as prefix of name or postfix of
+the stash name.
+
+Has the same side-effects and as C<gv_fetchmeth()>. C<name> should be
+writable if contains C<':'> or C<'\''>.
+
+ GV* gv_fetchmethod _((HV* stash, char* name));
+
=item gv_stashpv
Returns a pointer to the stash for a specified package. If C<create> is set
it will be upgraded to one. If C<classname> is non-null then the new SV will
be blessed in the specified package. The new SV is returned and its
reference count is 1.
+
SV* newSVrv _((SV* rv, char* classname));
=item newSVsv
=head1 DATE
-Version 26.1: 1996/12/20
+Version 28: 1996/12/27