Switch Perl_hv_common() to returning void * rather than HE *.
Nicholas Clark [Thu, 20 Sep 2007 12:59:25 +0000 (12:59 +0000)]
p4raw-id: //depot/perl@31926

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

index 5af749f..265c4ab 100644 (file)
--- a/embed.fnc
+++ b/embed.fnc
@@ -304,7 +304,7 @@ ApdR        |bool   |hv_exists      |NULLOK HV* tb|NN const char* key|I32 klen
 AbmdR  |bool   |hv_exists_ent  |NULLOK HV* tb|NN SV* key|U32 hash
 Apd    |SV**   |hv_fetch       |NULLOK HV* tb|NN const char* key|I32 klen|I32 lval
 Abmd   |HE*    |hv_fetch_ent   |NULLOK HV* tb|NN SV* key|I32 lval|U32 hash
-Ap     |HE*    |hv_common      |NULLOK HV* tb|NULLOK SV* keysv \
+Ap     |void*  |hv_common      |NULLOK HV* tb|NULLOK SV* keysv \
                                |NULLOK const char* key|STRLEN klen|int flags \
                                |int action|NULLOK SV* val|U32 hash
 Ap     |void   |hv_free_ent    |NN HV* hv|NULLOK HE* entryK
diff --git a/hv.c b/hv.c
index 1b8f74c..521ce2b 100644 (file)
--- a/hv.c
+++ b/hv.c
@@ -253,8 +253,8 @@ Perl_hv_store(pTHX_ HV *hv, const char *key, I32 klen_i32, SV *val, U32 hash)
        klen = klen_i32;
        flags = 0;
     }
-    hek = hv_common(hv, NULL, key, klen, flags,
-                   (HV_FETCH_ISSTORE|HV_FETCH_JUST_SV), val, hash);
+    hek = (HE *) hv_common(hv, NULL, key, klen, flags,
+                          (HV_FETCH_ISSTORE|HV_FETCH_JUST_SV), val, hash);
     return hek ? &HeVAL(hek) : NULL;
 }
 
@@ -263,8 +263,9 @@ SV**
 Perl_hv_store_flags(pTHX_ HV *hv, const char *key, I32 klen, SV *val,
                  register U32 hash, int flags)
 {
-    HE * const hek = hv_common(hv, NULL, key, klen, flags,
-                              (HV_FETCH_ISSTORE|HV_FETCH_JUST_SV), val, hash);
+    HE * const hek = (HE *) hv_common(hv, NULL, key, klen, flags,
+                                     (HV_FETCH_ISSTORE|HV_FETCH_JUST_SV), val,
+                                     hash);
     return hek ? &HeVAL(hek) : NULL;
 }
 
@@ -351,9 +352,9 @@ Perl_hv_fetch(pTHX_ HV *hv, const char *key, I32 klen_i32, I32 lval)
        klen = klen_i32;
        flags = 0;
     }
-    hek = hv_common(hv, NULL, key, klen, flags, lval
-                   ? (HV_FETCH_JUST_SV | HV_FETCH_LVALUE) : HV_FETCH_JUST_SV,
-                   NULL, 0);
+    hek = (HE *) hv_common(hv, NULL, key, klen, flags,
+                          lval ? (HV_FETCH_JUST_SV | HV_FETCH_LVALUE)
+                          : HV_FETCH_JUST_SV, NULL, 0);
     return hek ? &HeVAL(hek) : NULL;
 }
 
@@ -386,7 +387,7 @@ information on how to use this function on tied hashes.
 =cut
 */
 
-HE *
+void *
 Perl_hv_common(pTHX_ HV *hv, SV *keysv, const char *key, STRLEN klen,
               int flags, int action, SV *val, register U32 hash)
 {
@@ -498,26 +499,25 @@ Perl_hv_common(pTHX_ HV *hv, SV *keysv, const char *key, STRLEN klen,
                        const char * const nkey = strupr(savepvn(key,klen));
                        /* Note that this fetch is for nkey (the uppercased
                           key) whereas the store is for key (the original)  */
-                       entry = hv_common(hv, NULL, nkey, klen,
-                                         HVhek_FREEKEY, /* free nkey */
-                                         0 /* non-LVAL fetch */
-                                         | HV_DISABLE_UVAR_XKEY,
-                                         NULL /* no value */,
-                                         0 /* compute hash */);
+                       void *result = hv_common(hv, NULL, nkey, klen,
+                                                HVhek_FREEKEY, /* free nkey */
+                                                0 /* non-LVAL fetch */
+                                                | HV_DISABLE_UVAR_XKEY,
+                                                NULL /* no value */,
+                                                0 /* compute hash */);
                        if (!entry && (action & HV_FETCH_LVALUE)) {
                            /* This call will free key if necessary.
                               Do it this way to encourage compiler to tail
                               call optimise.  */
-                           entry = hv_common(hv, keysv, key, klen,
-                                             flags,
-                                             HV_FETCH_ISSTORE
-                                             | HV_DISABLE_UVAR_XKEY,
-                                             newSV(0), hash);
+                           result = hv_common(hv, keysv, key, klen, flags,
+                                              HV_FETCH_ISSTORE
+                                              | HV_DISABLE_UVAR_XKEY,
+                                              newSV(0), hash);
                        } else {
                            if (flags & HVhek_FREEKEY)
                                Safefree(key);
                        }
-                       return entry;
+                       return result;
                    }
            }
 #endif
@@ -971,9 +971,10 @@ S_hv_delete_common(pTHX_ HV *hv, SV *keysv, const char *key, STRLEN klen,
 
        if (needs_copy) {
            SV *sv;
-           entry = hv_common(hv, keysv, key, klen, k_flags & ~HVhek_FREEKEY,
-                             HV_FETCH_LVALUE|HV_DISABLE_UVAR_XKEY, NULL,
-                             hash);
+           entry = (HE *) hv_common(hv, keysv, key, klen,
+                                    k_flags & ~HVhek_FREEKEY,
+                                    HV_FETCH_LVALUE|HV_DISABLE_UVAR_XKEY,
+                                    NULL, hash);
            sv = entry ? HeVAL(entry) : NULL;
            if (sv) {
                if (SvMAGICAL(sv)) {
diff --git a/hv.h b/hv.h
index f91443d..8ca69fc 100644 (file)
--- a/hv.h
+++ b/hv.h
@@ -413,14 +413,15 @@ C<SV*>.
      hek)
 
 #define hv_store_ent(zlonk, awk, touche, zgruppp)                      \
-    hv_common((zlonk), (awk), NULL, 0, 0, HV_FETCH_ISSTORE, (touche), (zgruppp))
+    ((HE *) hv_common((zlonk), (awk), NULL, 0, 0, HV_FETCH_ISSTORE,    \
+                     (touche), (zgruppp)))
 
 #define hv_exists_ent(zlonk, awk, zgruppp)                             \
     (hv_common((zlonk), (awk), NULL, 0, 0, HV_FETCH_ISEXISTS, 0, (zgruppp))\
      ? TRUE : FALSE)
 #define hv_fetch_ent(zlonk, awk, touche, zgruppp)                      \
-    hv_common((zlonk), (awk), NULL, 0, 0, ((touche) ? HV_FETCH_LVALUE : 0), \
-             NULL, (zgruppp))
+    ((HE *) hv_common((zlonk), (awk), NULL, 0, 0,                      \
+                     ((touche) ? HV_FETCH_LVALUE : 0), NULL, (zgruppp)))
 #define hv_delete_ent(zlonk, awk, touche, zgruppp)                     \
     ((SV *) hv_common((zlonk), (awk), NULL, 0, 0, (touche) | HV_DELETE,        \
                      NULL, (zgruppp)))
diff --git a/proto.h b/proto.h
index d5e1887..e5cf5b7 100644 (file)
--- a/proto.h
+++ b/proto.h
@@ -704,7 +704,7 @@ PERL_CALLCONV SV**  Perl_hv_fetch(pTHX_ HV* tb, const char* key, I32 klen, I32 lv
 /* PERL_CALLCONV HE*   Perl_hv_fetch_ent(pTHX_ HV* tb, SV* key, I32 lval, U32 hash)
                        __attribute__nonnull__(pTHX_2); */
 
-PERL_CALLCONV HE*      Perl_hv_common(pTHX_ HV* tb, SV* keysv, const char* key, STRLEN klen, int flags, int action, SV* val, U32 hash);
+PERL_CALLCONV void*    Perl_hv_common(pTHX_ HV* tb, SV* keysv, const char* key, STRLEN klen, int flags, int action, SV* val, U32 hash);
 PERL_CALLCONV void     Perl_hv_free_ent(pTHX_ HV* hv, HE* entryK)
                        __attribute__nonnull__(pTHX_1);