diff options
author | Nicholas Clark <nick@ccl4.org> | 2007-09-20 12:59:25 +0000 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2007-09-20 12:59:25 +0000 |
commit | 63c893452f9c16b03be0a54c60b062d7e98a4471 (patch) | |
tree | 2b46f4fd5714ded00fbea5380060e615bf41a84b | |
parent | b8934dab8e60c1d376ff929f8bed2d4864e46219 (diff) | |
download | perl-63c893452f9c16b03be0a54c60b062d7e98a4471.tar.gz |
Switch Perl_hv_common() to returning void * rather than HE *.
p4raw-id: //depot/perl@31926
-rw-r--r-- | embed.fnc | 2 | ||||
-rw-r--r-- | hv.c | 47 | ||||
-rw-r--r-- | hv.h | 7 | ||||
-rw-r--r-- | proto.h | 2 |
4 files changed, 30 insertions, 28 deletions
@@ -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 @@ -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)) { @@ -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))) @@ -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); |