From: Steven Schubiger Date: Sat, 1 Mar 2008 19:29:53 +0000 (+0100) Subject: Re: [PATCH] sv.c: consting X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=2b021c53857fc8f84c88814fb57222878208d85f;p=p5sagit%2Fp5-mst-13.2.git Re: [PATCH] sv.c: consting Message-ID: <20080301182953.GB16742@refcnt.homeunix.org> p4raw-id: //depot/perl@33406 --- diff --git a/embed.fnc b/embed.fnc index fa71e38..95813b1 100644 --- a/embed.fnc +++ b/embed.fnc @@ -597,7 +597,7 @@ Apa |OP* |newPMOP |I32 type|I32 flags Apa |OP* |newPVOP |I32 type|I32 flags|NULLOK char* pv Apa |SV* |newRV |NN SV* sv Apda |SV* |newRV_noinc |NN SV* sv -Apda |SV* |newSV |STRLEN len +Apda |SV* |newSV |const STRLEN len Apa |OP* |newSVREF |NN OP* o Apa |OP* |newSVOP |I32 type|I32 flags|NN SV* sv Apda |SV* |newSViv |IV i @@ -854,7 +854,7 @@ Apd |int |sv_backoff |NN SV *const sv Apd |SV* |sv_bless |NN SV* sv|NN HV* stash Afpd |void |sv_catpvf |NN SV* sv|NN const char* pat|... Apd |void |sv_vcatpvf |NN SV* sv|NN const char* pat|NULLOK va_list* args -Apd |void |sv_catpv |NN SV* sv|NULLOK const char* ptr +Apd |void |sv_catpv |NN SV *const sv|NULLOK const char* ptr Amdb |void |sv_catpvn |NN SV *dsv|NN const char *sstr|STRLEN len Amdb |void |sv_catsv |NN SV *dstr|NULLOK SV *sstr Apd |void |sv_chop |NN SV *const sv|NULLOK const char *const ptr @@ -880,16 +880,17 @@ pd |void |sv_free_arenas Apd |char* |sv_gets |NN SV* sv|NN PerlIO* fp|I32 append Apd |char* |sv_grow |NN SV *const sv|STRLEN newlen Apd |void |sv_inc |NULLOK SV* sv -Apd |void |sv_insert |NN SV *bigstr|STRLEN offset|STRLEN len \ - |NN const char *little|STRLEN littlelen +Apd |void |sv_insert |NN SV *const bigstr|const STRLEN offset|const STRLEN len \ + |NN const char *const little|const STRLEN littlelen Apd |int |sv_isa |NULLOK SV* sv|NN const char* name Apd |int |sv_isobject |NULLOK SV* sv Apd |STRLEN |sv_len |NULLOK SV* sv Apd |STRLEN |sv_len_utf8 |NULLOK SV* sv -Apd |void |sv_magic |NN SV* sv|NULLOK SV* obj|int how|NULLOK const char* name \ - |I32 namlen -Apd |MAGIC *|sv_magicext |NN SV* sv|NULLOK SV* obj|int how|NULLOK const MGVTBL *vtbl \ - |NULLOK const char* name|I32 namlen +Apd |void |sv_magic |NN SV *const sv|NULLOK SV *const obj|const int how \ + |NULLOK const char *const name|I32 namlen +Apd |MAGIC *|sv_magicext |NN SV *const sv|NULLOK SV *const obj|const int how \ + |NULLOK const MGVTBL *const vtbl|NULLOK const char *const name \ + |const I32 namlen ApdaR |SV* |sv_mortalcopy |NULLOK SV* oldsv ApdR |SV* |sv_newmortal Apd |SV* |sv_newref |NULLOK SV* sv @@ -922,7 +923,7 @@ Apd |void |sv_setpvn |NN SV *const sv|NULLOK const char *const ptr|const STRLEN Amdb |void |sv_setsv |NN SV *dstr|NULLOK SV *sstr Amdb |void |sv_taint |NN SV* sv ApdR |bool |sv_tainted |NN SV* sv -Apd |int |sv_unmagic |NN SV* sv|int type +Apd |int |sv_unmagic |NN SV *const sv|const int type Apdmb |void |sv_unref |NN SV* sv Apd |void |sv_unref_flags |NN SV *ref|U32 flags Apd |void |sv_untaint |NN SV* sv @@ -1030,7 +1031,7 @@ Ap |int |runops_standard Ap |int |runops_debug Afpd |void |sv_catpvf_mg |NN SV *sv|NN const char* pat|... Apd |void |sv_vcatpvf_mg |NN SV* sv|NN const char* pat|NULLOK va_list* args -Apd |void |sv_catpv_mg |NN SV *sv|NULLOK const char *ptr +Apd |void |sv_catpv_mg |NN SV *const sv|NULLOK const char *const ptr Apdbm |void |sv_catpvn_mg |NN SV *sv|NN const char *ptr|STRLEN len Apdbm |void |sv_catsv_mg |NN SV *dsv|NULLOK SV *ssv Afpd |void |sv_setpvf_mg |NN SV *sv|NN const char* pat|... @@ -1085,7 +1086,7 @@ ApdM |bool |sv_utf8_decode |NN SV *const sv Apdmb |void |sv_force_normal|NN SV *sv Apd |void |sv_force_normal_flags|NN SV *const sv|const U32 flags Ap |void |tmps_grow |I32 n -Apd |SV* |sv_rvweaken |NN SV *sv +Apd |SV* |sv_rvweaken |NN SV *const sv p |int |magic_killbackrefs|NN SV *sv|NN MAGIC *mg Ap |OP* |newANONATTRSUB |I32 floor|NULLOK OP *proto|NULLOK OP *attrs|NULLOK OP *block Ap |CV* |newATTRSUB |I32 floor|NULLOK OP *o|NULLOK OP *proto|NULLOK OP *attrs|NULLOK OP *block @@ -1528,11 +1529,11 @@ s |SV* |save_scalar_at |NN SV **sptr #endif #if defined(PERL_IN_GV_C) || defined(PERL_IN_SV_C) || defined(PERL_IN_PAD_C) || defined(PERL_DECL_PROT) -po |void |sv_add_backref |NN SV *tsv|NN SV *sv +po |void |sv_add_backref |NN SV *const tsv|NN SV *const sv #endif #if defined(PERL_IN_HV_C) || defined(PERL_IN_MG_C) || defined(PERL_IN_SV_C) || defined(PERL_DECL_PROT) -poM |int |sv_kill_backrefs |NN SV *sv|NN AV *av +poM |int |sv_kill_backrefs |NN SV *const sv|NN AV *const av #endif #if defined(PERL_IN_SV_C) || defined(PERL_DECL_PROT) @@ -1540,7 +1541,7 @@ nsR |char * |uiv_2buf |NN char *const buf|const IV iv|UV uv|const int is_uv|NN c s |void |sv_unglob |NN SV* sv s |void |not_a_number |NN SV *const sv s |I32 |visit |NN SVFUNC_t f|const U32 flags|const U32 mask -s |void |sv_del_backref |NN SV *tsv|NN SV *sv +s |void |sv_del_backref |NN SV *const tsv|NN SV *const sv sR |SV * |varname |NULLOK GV *gv|const char gvtype|PADOFFSET targ \ |NULLOK SV *keyname|I32 aindex|int subscript_type # ifdef DEBUGGING diff --git a/pod/perlapi.pod b/pod/perlapi.pod index 3c68111..cc2fc73 100644 --- a/pod/perlapi.pod +++ b/pod/perlapi.pod @@ -5127,7 +5127,7 @@ This aid has been superseded by a new build option, PERL_MEM_LOG (see L). The older API is still there for use in XS modules supporting older perls. - SV* newSV(STRLEN len) + SV* newSV(const STRLEN len) =for hackers Found in file sv.c @@ -5472,7 +5472,7 @@ Concatenates the string onto the end of the string which is in the SV. If the SV has the UTF-8 status set, then the bytes appended should be valid UTF-8. Handles 'get' magic, but not 'set' magic. See C. - void sv_catpv(SV* sv, const char* ptr) + void sv_catpv(SV *const sv, const char* ptr) =for hackers Found in file sv.c @@ -5546,7 +5546,7 @@ X Like C, but also handles 'set' magic. - void sv_catpv_mg(SV *sv, const char *ptr) + void sv_catpv_mg(SV *const sv, const char *const ptr) =for hackers Found in file sv.c @@ -5757,7 +5757,7 @@ X Inserts a string at the specified offset/length within the SV. Similar to the Perl substr() function. - void sv_insert(SV *bigstr, STRLEN offset, STRLEN len, const char *little, STRLEN littlelen) + void sv_insert(SV *const bigstr, const STRLEN offset, const STRLEN len, const char *const little, const STRLEN littlelen) =for hackers Found in file sv.c @@ -5820,7 +5820,7 @@ handling of the C and C arguments. You need to use C to add magic to SvREADONLY SVs and also to add more than one instance of the same 'how'. - void sv_magic(SV* sv, SV* obj, int how, const char* name, I32 namlen) + void sv_magic(SV *const sv, SV *const obj, const int how, const char *const name, I32 namlen) =for hackers Found in file sv.c @@ -5842,7 +5842,7 @@ to contain an C and is stored as-is with its REFCNT incremented. (This is now used as a subroutine by C.) - MAGIC * sv_magicext(SV* sv, SV* obj, int how, const MGVTBL *vtbl, const char* name, I32 namlen) + MAGIC * sv_magicext(SV *const sv, SV *const obj, const int how, const MGVTBL *const vtbl, const char *const name, const I32 namlen) =for hackers Found in file sv.c @@ -6002,7 +6002,7 @@ push a back-reference to this RV onto the array of backreferences associated with that magic. If the RV is magical, set magic will be called after the RV is cleared. - SV* sv_rvweaken(SV *sv) + SV* sv_rvweaken(SV *const sv) =for hackers Found in file sv.c @@ -6323,7 +6323,7 @@ X Removes all magic of type C from an SV. - int sv_unmagic(SV* sv, int type) + int sv_unmagic(SV *const sv, const int type) =for hackers Found in file sv.c diff --git a/proto.h b/proto.h index ce47ac9..ff28d96 100644 --- a/proto.h +++ b/proto.h @@ -2159,7 +2159,7 @@ PERL_CALLCONV SV* Perl_newRV_noinc(pTHX_ SV* sv) #define PERL_ARGS_ASSERT_NEWRV_NOINC \ assert(sv) -PERL_CALLCONV SV* Perl_newSV(pTHX_ STRLEN len) +PERL_CALLCONV SV* Perl_newSV(pTHX_ const STRLEN len) __attribute__malloc__ __attribute__warn_unused_result__; @@ -3091,7 +3091,7 @@ PERL_CALLCONV void Perl_sv_vcatpvf(pTHX_ SV* sv, const char* pat, va_list* args) #define PERL_ARGS_ASSERT_SV_VCATPVF \ assert(sv); assert(pat) -PERL_CALLCONV void Perl_sv_catpv(pTHX_ SV* sv, const char* ptr) +PERL_CALLCONV void Perl_sv_catpv(pTHX_ SV *const sv, const char* ptr) __attribute__nonnull__(pTHX_1); #define PERL_ARGS_ASSERT_SV_CATPV \ assert(sv) @@ -3182,7 +3182,7 @@ PERL_CALLCONV char* Perl_sv_grow(pTHX_ SV *const sv, STRLEN newlen) assert(sv) PERL_CALLCONV void Perl_sv_inc(pTHX_ SV* sv); -PERL_CALLCONV void Perl_sv_insert(pTHX_ SV *bigstr, STRLEN offset, STRLEN len, const char *little, STRLEN littlelen) +PERL_CALLCONV void Perl_sv_insert(pTHX_ SV *const bigstr, const STRLEN offset, const STRLEN len, const char *const little, const STRLEN littlelen) __attribute__nonnull__(pTHX_1) __attribute__nonnull__(pTHX_4); #define PERL_ARGS_ASSERT_SV_INSERT \ @@ -3196,12 +3196,12 @@ PERL_CALLCONV int Perl_sv_isa(pTHX_ SV* sv, const char* name) PERL_CALLCONV int Perl_sv_isobject(pTHX_ SV* sv); PERL_CALLCONV STRLEN Perl_sv_len(pTHX_ SV* sv); PERL_CALLCONV STRLEN Perl_sv_len_utf8(pTHX_ SV* sv); -PERL_CALLCONV void Perl_sv_magic(pTHX_ SV* sv, SV* obj, int how, const char* name, I32 namlen) +PERL_CALLCONV void Perl_sv_magic(pTHX_ SV *const sv, SV *const obj, const int how, const char *const name, I32 namlen) __attribute__nonnull__(pTHX_1); #define PERL_ARGS_ASSERT_SV_MAGIC \ assert(sv) -PERL_CALLCONV MAGIC * Perl_sv_magicext(pTHX_ SV* sv, SV* obj, int how, const MGVTBL *vtbl, const char* name, I32 namlen) +PERL_CALLCONV MAGIC * Perl_sv_magicext(pTHX_ SV *const sv, SV *const obj, const int how, const MGVTBL *const vtbl, const char *const name, const I32 namlen) __attribute__nonnull__(pTHX_1); #define PERL_ARGS_ASSERT_SV_MAGICEXT \ assert(sv) @@ -3358,7 +3358,7 @@ PERL_CALLCONV bool Perl_sv_tainted(pTHX_ SV* sv) #define PERL_ARGS_ASSERT_SV_TAINTED \ assert(sv) -PERL_CALLCONV int Perl_sv_unmagic(pTHX_ SV* sv, int type) +PERL_CALLCONV int Perl_sv_unmagic(pTHX_ SV *const sv, const int type) __attribute__nonnull__(pTHX_1); #define PERL_ARGS_ASSERT_SV_UNMAGIC \ assert(sv) @@ -3758,7 +3758,7 @@ PERL_CALLCONV void Perl_sv_vcatpvf_mg(pTHX_ SV* sv, const char* pat, va_list* ar #define PERL_ARGS_ASSERT_SV_VCATPVF_MG \ assert(sv); assert(pat) -PERL_CALLCONV void Perl_sv_catpv_mg(pTHX_ SV *sv, const char *ptr) +PERL_CALLCONV void Perl_sv_catpv_mg(pTHX_ SV *const sv, const char *const ptr) __attribute__nonnull__(pTHX_1); #define PERL_ARGS_ASSERT_SV_CATPV_MG \ assert(sv) @@ -3970,7 +3970,7 @@ PERL_CALLCONV void Perl_sv_force_normal_flags(pTHX_ SV *const sv, const U32 flag assert(sv) PERL_CALLCONV void Perl_tmps_grow(pTHX_ I32 n); -PERL_CALLCONV SV* Perl_sv_rvweaken(pTHX_ SV *sv) +PERL_CALLCONV SV* Perl_sv_rvweaken(pTHX_ SV *const sv) __attribute__nonnull__(pTHX_1); #define PERL_ARGS_ASSERT_SV_RVWEAKEN \ assert(sv) @@ -5473,7 +5473,7 @@ STATIC SV* S_save_scalar_at(pTHX_ SV **sptr) #endif #if defined(PERL_IN_GV_C) || defined(PERL_IN_SV_C) || defined(PERL_IN_PAD_C) || defined(PERL_DECL_PROT) -PERL_CALLCONV void Perl_sv_add_backref(pTHX_ SV *tsv, SV *sv) +PERL_CALLCONV void Perl_sv_add_backref(pTHX_ SV *const tsv, SV *const sv) __attribute__nonnull__(pTHX_1) __attribute__nonnull__(pTHX_2); #define PERL_ARGS_ASSERT_SV_ADD_BACKREF \ @@ -5482,7 +5482,7 @@ PERL_CALLCONV void Perl_sv_add_backref(pTHX_ SV *tsv, SV *sv) #endif #if defined(PERL_IN_HV_C) || defined(PERL_IN_MG_C) || defined(PERL_IN_SV_C) || defined(PERL_DECL_PROT) -PERL_CALLCONV int Perl_sv_kill_backrefs(pTHX_ SV *sv, AV *av) +PERL_CALLCONV int Perl_sv_kill_backrefs(pTHX_ SV *const sv, AV *const av) __attribute__nonnull__(pTHX_1) __attribute__nonnull__(pTHX_2); #define PERL_ARGS_ASSERT_SV_KILL_BACKREFS \ @@ -5513,7 +5513,7 @@ STATIC I32 S_visit(pTHX_ SVFUNC_t f, const U32 flags, const U32 mask) #define PERL_ARGS_ASSERT_VISIT \ assert(f) -STATIC void S_sv_del_backref(pTHX_ SV *tsv, SV *sv) +STATIC void S_sv_del_backref(pTHX_ SV *const tsv, SV *const sv) __attribute__nonnull__(pTHX_1) __attribute__nonnull__(pTHX_2); #define PERL_ARGS_ASSERT_SV_DEL_BACKREF \ diff --git a/sv.c b/sv.c index 932e9ce..cc22016 100644 --- a/sv.c +++ b/sv.c @@ -4540,7 +4540,7 @@ valid UTF-8. Handles 'get' magic, but not 'set' magic. See C. =cut */ void -Perl_sv_catpv(pTHX_ register SV *sv, register const char *ptr) +Perl_sv_catpv(pTHX_ register SV *const sv, register const char *ptr) { dVAR; register STRLEN len; @@ -4571,7 +4571,7 @@ Like C, but also handles 'set' magic. */ void -Perl_sv_catpv_mg(pTHX_ register SV *sv, register const char *ptr) +Perl_sv_catpv_mg(pTHX_ register SV *const sv, register const char *const ptr) { PERL_ARGS_ASSERT_SV_CATPV_MG; @@ -4597,7 +4597,7 @@ modules supporting older perls. */ SV * -Perl_newSV(pTHX_ STRLEN len) +Perl_newSV(pTHX_ const STRLEN len) { dVAR; register SV *sv; @@ -4629,8 +4629,8 @@ to contain an C and is stored as-is with its REFCNT incremented. =cut */ MAGIC * -Perl_sv_magicext(pTHX_ SV* sv, SV* obj, int how, const MGVTBL *vtable, - const char* name, I32 namlen) +Perl_sv_magicext(pTHX_ SV *const sv, SV *const obj, const int how, + const MGVTBL *const vtable, const char *const name, const I32 namlen) { dVAR; MAGIC* mg; @@ -4714,7 +4714,8 @@ to add more than one instance of the same 'how'. */ void -Perl_sv_magic(pTHX_ register SV *sv, SV *obj, int how, const char *name, I32 namlen) +Perl_sv_magic(pTHX_ register SV *const sv, SV *const obj, const int how, + const char *const name, const I32 namlen) { dVAR; const MGVTBL *vtable; @@ -4901,7 +4902,7 @@ Removes all magic of type C from an SV. */ int -Perl_sv_unmagic(pTHX_ SV *sv, int type) +Perl_sv_unmagic(pTHX_ SV *const sv, const int type) { MAGIC* mg; MAGIC** mgp; @@ -4954,7 +4955,7 @@ called after the RV is cleared. */ SV * -Perl_sv_rvweaken(pTHX_ SV *sv) +Perl_sv_rvweaken(pTHX_ SV *const sv) { SV *tsv; @@ -4981,7 +4982,7 @@ Perl_sv_rvweaken(pTHX_ SV *sv) */ void -Perl_sv_add_backref(pTHX_ SV *tsv, SV *sv) +Perl_sv_add_backref(pTHX_ SV *const tsv, SV *const sv) { dVAR; AV *av; @@ -5037,7 +5038,7 @@ Perl_sv_add_backref(pTHX_ SV *tsv, SV *sv) */ STATIC void -S_sv_del_backref(pTHX_ SV *tsv, SV *sv) +S_sv_del_backref(pTHX_ SV *const tsv, SV *const sv) { dVAR; AV *av = NULL; @@ -5089,7 +5090,7 @@ S_sv_del_backref(pTHX_ SV *tsv, SV *sv) } int -Perl_sv_kill_backrefs(pTHX_ SV *sv, AV *av) +Perl_sv_kill_backrefs(pTHX_ SV *const sv, AV *const av) { SV **svp = AvARRAY(av); @@ -5141,7 +5142,8 @@ the Perl substr() function. */ void -Perl_sv_insert(pTHX_ SV *bigstr, STRLEN offset, STRLEN len, const char *little, STRLEN littlelen) +Perl_sv_insert(pTHX_ SV *const bigstr, const STRLEN offset, const STRLEN len, + const char *const little, const STRLEN littlelen) { dVAR; register char *big;