summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2007-09-20 12:59:25 +0000
committerNicholas Clark <nick@ccl4.org>2007-09-20 12:59:25 +0000
commit63c893452f9c16b03be0a54c60b062d7e98a4471 (patch)
tree2b46f4fd5714ded00fbea5380060e615bf41a84b
parentb8934dab8e60c1d376ff929f8bed2d4864e46219 (diff)
downloadperl-63c893452f9c16b03be0a54c60b062d7e98a4471.tar.gz
Switch Perl_hv_common() to returning void * rather than HE *.
p4raw-id: //depot/perl@31926
-rw-r--r--embed.fnc2
-rw-r--r--hv.c47
-rw-r--r--hv.h7
-rw-r--r--proto.h2
4 files changed, 30 insertions, 28 deletions
diff --git a/embed.fnc b/embed.fnc
index 5af749f661..265c4ab6b4 100644
--- 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 1b8f74c6af..521ce2bb5c 100644
--- 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 f91443dddc..8ca69fc1aa 100644
--- 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 d5e1887c8d..e5cf5b707f 100644
--- 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);