This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Split out part of hv_auxinit() so it can be reused
authorYves Orton <demerphq@gmail.com>
Sat, 1 Mar 2014 14:49:28 +0000 (15:49 +0100)
committerYves Orton <demerphq@gmail.com>
Tue, 18 Mar 2014 07:37:04 +0000 (08:37 +0100)
Changes nothing except that it introduces hv_auxinit_interal() which
does part of the job of hv_auxinit(), so that we can call it from
somewhere else in the next commit.

embed.fnc
embed.h
hv.c
proto.h

index 1e96cbc..c85d219 100644 (file)
--- a/embed.fnc
+++ b/embed.fnc
@@ -1840,6 +1840,7 @@ sR        |HEK*   |share_hek_flags|NN const char *str|I32 len|U32 hash|int flags
 rs     |void   |hv_notallowed  |int flags|NN const char *key|I32 klen|NN const char *msg
 in     |U32|ptr_hash|PTRV u
 s      |struct xpvhv_aux*|hv_auxinit|NN HV *hv
+sn     |struct xpvhv_aux*|hv_auxinit_internal|NN struct xpvhv_aux *iter
 sM     |SV*    |hv_delete_common|NULLOK HV *hv|NULLOK SV *keysv \
                |NULLOK const char *key|STRLEN klen|int k_flags|I32 d_flags \
                |U32 hash
diff --git a/embed.h b/embed.h
index facb415..824d294 100644 (file)
--- a/embed.h
+++ b/embed.h
 #define hfreeentries(a)                S_hfreeentries(aTHX_ a)
 #define hsplit(a,b,c)          S_hsplit(aTHX_ a,b,c)
 #define hv_auxinit(a)          S_hv_auxinit(aTHX_ a)
+#define hv_auxinit_internal    S_hv_auxinit_internal
 #define hv_delete_common(a,b,c,d,e,f,g)        S_hv_delete_common(aTHX_ a,b,c,d,e,f,g)
 #define hv_free_ent_ret(a,b)   S_hv_free_ent_ret(aTHX_ a,b)
 #define hv_magic_check         S_hv_magic_check
diff --git a/hv.c b/hv.c
index 9d80659..28e5ecf 100644 (file)
--- a/hv.c
+++ b/hv.c
@@ -1938,6 +1938,23 @@ PERL_STATIC_INLINE U32 S_ptr_hash(PTRV u) {
     return (U32)u;
 }
 
+static struct xpvhv_aux*
+S_hv_auxinit_internal(struct xpvhv_aux *iter) {
+    PERL_ARGS_ASSERT_HV_AUXINIT_INTERNAL;
+    iter->xhv_riter = -1;      /* HvRITER(hv) = -1 */
+    iter->xhv_eiter = NULL;    /* HvEITER(hv) = NULL */
+#ifdef PERL_HASH_RANDOMIZE_KEYS
+    iter->xhv_last_rand = iter->xhv_rand;
+#endif
+    iter->xhv_fill_lazy = 0;
+    iter->xhv_name_u.xhvnameu_name = 0;
+    iter->xhv_name_count = 0;
+    iter->xhv_backreferences = 0;
+    iter->xhv_mro_meta = NULL;
+    iter->xhv_aux_flags = 0;
+    return iter;
+}
+
 
 static struct xpvhv_aux*
 S_hv_auxinit(pTHX_ HV *hv) {
@@ -1971,18 +1988,7 @@ S_hv_auxinit(pTHX_ HV *hv) {
         iter = HvAUX(hv);
     }
 
-    iter->xhv_riter = -1;      /* HvRITER(hv) = -1 */
-    iter->xhv_eiter = NULL;    /* HvEITER(hv) = NULL */
-#ifdef PERL_HASH_RANDOMIZE_KEYS
-    iter->xhv_last_rand = iter->xhv_rand;
-#endif
-    iter->xhv_fill_lazy = 0;
-    iter->xhv_name_u.xhvnameu_name = 0;
-    iter->xhv_name_count = 0;
-    iter->xhv_backreferences = 0;
-    iter->xhv_mro_meta = NULL;
-    iter->xhv_aux_flags = 0;
-    return iter;
+    return hv_auxinit_internal(iter);
 }
 
 /*
diff --git a/proto.h b/proto.h
index 9b33013..b4f22dd 100644 (file)
--- a/proto.h
+++ b/proto.h
@@ -5863,6 +5863,11 @@ STATIC struct xpvhv_aux* S_hv_auxinit(pTHX_ HV *hv)
 #define PERL_ARGS_ASSERT_HV_AUXINIT    \
        assert(hv)
 
+STATIC struct xpvhv_aux*       S_hv_auxinit_internal(struct xpvhv_aux *iter)
+                       __attribute__nonnull__(1);
+#define PERL_ARGS_ASSERT_HV_AUXINIT_INTERNAL   \
+       assert(iter)
+
 STATIC SV*     S_hv_delete_common(pTHX_ HV *hv, SV *keysv, const char *key, STRLEN klen, int k_flags, I32 d_flags, U32 hash);
 STATIC SV*     S_hv_free_ent_ret(pTHX_ HV *hv, HE *entry)
                        __attribute__nonnull__(pTHX_1)