X-Git-Url: https://perl5.git.perl.org/perl5.git/blobdiff_plain/c8b388b0c776dab4a28db03739aff4d64daccada..d022bb19f99bdcaafe3758b24d031a0f0450e623:/hv.c diff --git a/hv.c b/hv.c index 04129f8..eccae62 100644 --- a/hv.c +++ b/hv.c @@ -260,7 +260,9 @@ if all your code does is create SVs then store them in a hash, C will own the only reference to the new SV, and your code doesn't need to do anything further to tidy up. Note that C only reads the C; unlike C it does not take ownership of it, so maintaining the correct -reference count on C is entirely the caller's responsibility. C +reference count on C is entirely the caller's responsibility. The reason +it does not take ownership, is that C is not used after this function +returns, and so can be freed immediately. C is not implemented as a call to C, and does not create a temporary SV for the key, so if your key data is not already in SV form then use C in preference to C. @@ -1279,7 +1281,7 @@ S_hv_delete_common(pTHX_ HV *hv, SV *keysv, const char *key, STRLEN klen, sv_2mortal((SV *)gv) ); } - else if (klen == 3 && strBEGINs(key, "ISA") && GvAV(gv)) { + else if (memEQs(key, klen, "ISA") && GvAV(gv)) { AV *isa = GvAV(gv); MAGIC *mg = mg_find((SV*)isa, PERL_MAGIC_isa); @@ -1295,7 +1297,7 @@ S_hv_delete_common(pTHX_ HV *hv, SV *keysv, const char *key, STRLEN klen, SV **svp, **end; strip_magic: svp = AvARRAY(isa); - end = svp + AvFILLp(isa)+1; + end = svp + (AvFILLp(isa)+1); while (svp < end) { if (*svp) mg_free_type(*svp, PERL_MAGIC_isaelem); @@ -1669,7 +1671,7 @@ Perl_newHVhv(pTHX_ HV *ohv) } /* -=for apidoc Am|HV *|hv_copy_hints_hv|HV *ohv +=for apidoc hv_copy_hints_hv A specialised version of L for copying C<%^H>. C must be a pointer to a hash (which may have C<%^H> magic, but should be generally @@ -2394,17 +2396,17 @@ Perl_hv_name_set(pTHX_ HV *hv, const char *name, U32 len, U32 flags) if (iter->xhv_name_u.xhvnameu_name) { if(iter->xhv_name_count) { if(flags & HV_NAME_SETALL) { - HEK ** const name = HvAUX(hv)->xhv_name_u.xhvnameu_names; - HEK **hekp = name + ( + HEK ** const this_name = HvAUX(hv)->xhv_name_u.xhvnameu_names; + HEK **hekp = this_name + ( iter->xhv_name_count < 0 ? -iter->xhv_name_count : iter->xhv_name_count ); - while(hekp-- > name+1) + while(hekp-- > this_name+1) unshare_hek_or_pvn(*hekp, 0, 0, 0); /* The first elem may be null. */ - if(*name) unshare_hek_or_pvn(*name, 0, 0, 0); - Safefree(name); + if(*this_name) unshare_hek_or_pvn(*this_name, 0, 0, 0); + Safefree(this_name); iter = HvAUX(hv); /* may been realloced */ spot = &iter->xhv_name_u.xhvnameu_name; iter->xhv_name_count = 0; @@ -2670,6 +2672,8 @@ C<&PL_sv_placeholder>. Note that the implementation of placeholders and restricted hashes may change, and the implementation currently is insufficiently abstracted for any change to be tidy. +=for apidoc Amnh||HV_ITERNEXT_WANTPLACEHOLDERS + =cut */ @@ -3247,7 +3251,7 @@ S_refcounted_he_value(pTHX_ const struct refcounted_he *he) } /* -=for apidoc m|HV *|refcounted_he_chain_2hv|const struct refcounted_he *c|U32 flags +=for apidoc refcounted_he_chain_2hv Generates and returns a C representing the content of a C chain. @@ -3355,7 +3359,7 @@ Perl_refcounted_he_chain_2hv(pTHX_ const struct refcounted_he *chain, U32 flags) } /* -=for apidoc m|SV *|refcounted_he_fetch_pvn|const struct refcounted_he *chain|const char *keypv|STRLEN keylen|U32 hash|U32 flags +=for apidoc refcounted_he_fetch_pvn Search along a C chain for an entry with the key specified by C and C. If C has the C @@ -3445,7 +3449,7 @@ Perl_refcounted_he_fetch_pvn(pTHX_ const struct refcounted_he *chain, } /* -=for apidoc m|SV *|refcounted_he_fetch_pv|const struct refcounted_he *chain|const char *key|U32 hash|U32 flags +=for apidoc refcounted_he_fetch_pv Like L, but takes a nul-terminated string instead of a string/length pair. @@ -3462,7 +3466,7 @@ Perl_refcounted_he_fetch_pv(pTHX_ const struct refcounted_he *chain, } /* -=for apidoc m|SV *|refcounted_he_fetch_sv|const struct refcounted_he *chain|SV *key|U32 hash|U32 flags +=for apidoc refcounted_he_fetch_sv Like L, but takes a Perl scalar instead of a string/length pair. @@ -3489,7 +3493,7 @@ Perl_refcounted_he_fetch_sv(pTHX_ const struct refcounted_he *chain, } /* -=for apidoc m|struct refcounted_he *|refcounted_he_new_pvn|struct refcounted_he *parent|const char *keypv|STRLEN keylen|U32 hash|SV *value|U32 flags +=for apidoc refcounted_he_new_pvn Creates a new C. This consists of a single key/value pair and a reference to an existing C chain (which may @@ -3633,7 +3637,7 @@ Perl_refcounted_he_new_pvn(pTHX_ struct refcounted_he *parent, } /* -=for apidoc m|struct refcounted_he *|refcounted_he_new_pv|struct refcounted_he *parent|const char *key|U32 hash|SV *value|U32 flags +=for apidoc refcounted_he_new_pv Like L, but takes a nul-terminated string instead of a string/length pair. @@ -3650,7 +3654,7 @@ Perl_refcounted_he_new_pv(pTHX_ struct refcounted_he *parent, } /* -=for apidoc m|struct refcounted_he *|refcounted_he_new_sv|struct refcounted_he *parent|SV *key|U32 hash|SV *value|U32 flags +=for apidoc refcounted_he_new_sv Like L, but takes a Perl scalar instead of a string/length pair. @@ -3677,7 +3681,7 @@ Perl_refcounted_he_new_sv(pTHX_ struct refcounted_he *parent, } /* -=for apidoc m|void|refcounted_he_free|struct refcounted_he *he +=for apidoc refcounted_he_free Decrements the reference count of a C by one. If the reference count reaches zero the structure's memory is freed, which @@ -3717,7 +3721,7 @@ Perl_refcounted_he_free(pTHX_ struct refcounted_he *he) { } /* -=for apidoc m|struct refcounted_he *|refcounted_he_inc|struct refcounted_he *he +=for apidoc refcounted_he_inc Increment the reference count of a C. The pointer to the C is also returned. It is safe to pass a null pointer @@ -3744,8 +3748,14 @@ Perl_refcounted_he_inc(pTHX_ struct refcounted_he *he) /* =for apidoc cop_fetch_label -Returns the label attached to a cop. -The flags pointer may be set to C or 0. +Returns the label attached to a cop, and stores its length in bytes into +C<*len>. +Upon return, C<*flags> will be set to either C or 0. + +Alternatively, use the macro L>; +or if you don't need to know if the label is UTF-8 or not, the macro +L>; +or if you additionally dont need to know the length, L>. =cut */ @@ -3792,7 +3802,7 @@ Perl_cop_fetch_label(pTHX_ COP *const cop, STRLEN *len, U32 *flags) { Save a label into a C. You need to set flags to C -for a UTF-8 label. +for a UTF-8 label. Any other flag is ignored. =cut */