SV* newSVpvf(const char*, ...);
SV* newSVsv(SV*);
-C<STRLEN> is an integer type (Size_t, usually defined as size_t in
+C<STRLEN> is an integer type (C<Size_t>, usually defined as C<size_t> in
F<config.h>) guaranteed to be large enough to represent the size of
any string that perl can handle.
void sv_setpvn(SV*, const char*, STRLEN)
void sv_setpvf(SV*, const char*, ...);
void sv_vsetpvfn(SV*, const char*, STRLEN, va_list *,
- SV **, I32, bool *);
+ SV **, Size_t, bool *);
void sv_setsv(SV*, SV*);
Notice that you can choose to specify the length of the string to be
If you don't need the existing content of the SV, you can avoid some
copying with:
- sv_setpvn(sv, "", 0);
+ SvPVCLEAR(sv);
s = SvGROW(sv, needlen + 1);
/* something that modifies up to needlen bytes at s, but modifies
newlen bytes
The C<obj> argument is stored in the C<mg_obj> field of the C<MAGIC>
structure. If it is not the same as the C<sv> argument, the reference
count of the C<obj> object is incremented. If it is the same, or if
-the C<how> argument is C<PERL_MAGIC_arylen>, or if it is a NULL pointer,
-then C<obj> is merely stored, without the reference count being incremented.
+the C<how> argument is C<PERL_MAGIC_arylen>, C<PERL_MAGIC_regdatum>,
+C<PERL_MAGIC_regdata>, or if it is a NULL pointer, then C<obj> is merely
+stored, without the reference count being incremented.
See also C<sv_magicext> in L<perlapi> for a more flexible way to add magic
to an SV.
The C<MGVTBL> has five (or sometimes eight) pointers to the following
routine types:
- int (*svt_get)(SV* sv, MAGIC* mg);
- int (*svt_set)(SV* sv, MAGIC* mg);
- U32 (*svt_len)(SV* sv, MAGIC* mg);
- int (*svt_clear)(SV* sv, MAGIC* mg);
- int (*svt_free)(SV* sv, MAGIC* mg);
+ int (*svt_get) (pTHX_ SV* sv, MAGIC* mg);
+ int (*svt_set) (pTHX_ SV* sv, MAGIC* mg);
+ U32 (*svt_len) (pTHX_ SV* sv, MAGIC* mg);
+ int (*svt_clear)(pTHX_ SV* sv, MAGIC* mg);
+ int (*svt_free) (pTHX_ SV* sv, MAGIC* mg);
- int (*svt_copy)(SV *sv, MAGIC* mg, SV *nsv,
+ int (*svt_copy) (pTHX_ SV *sv, MAGIC* mg, SV *nsv,
const char *name, I32 namlen);
- int (*svt_dup)(MAGIC *mg, CLONE_PARAMS *param);
- int (*svt_local)(SV *nsv, MAGIC *mg);
+ int (*svt_dup) (pTHX_ MAGIC *mg, CLONE_PARAMS *param);
+ int (*svt_local)(pTHX_ SV *nsv, MAGIC *mg);
This MGVTBL structure is set at compile-time in F<perl.h> and there are
If you are printing addresses of pointers, use UVxf combined
with PTR2UV(), do not use %lx or %p.
-=head2 Formatted Printing of Size_t and SSize_t
+=head2 Formatted Printing of C<Size_t> and C<SSize_t>
The most general way to do this is to cast them to a UV or IV, and
print as in the