diff options
-rw-r--r-- | av.c | 26 | ||||
-rw-r--r-- | global.sym | 4 |
2 files changed, 30 insertions, 0 deletions
@@ -561,6 +561,32 @@ U32 hash; return av_store(av, ind, val); } +SV** +avhv_store_ent(av, keysv, val, hash) +AV *av; +SV *keysv; +SV *val; +U32 hash; +{ + SV **keys; + HE *he; + I32 ind; + + keys = av_fetch(av, 0, FALSE); + if (!keys || !SvROK(*keys) || SvTYPE(SvRV(*keys)) != SVt_PVHV) + croak("Can't coerce array into hash"); + he = hv_fetch_ent((HV*)SvRV(*keys), keysv, FALSE, hash); + if (he) { + ind = SvIV(HeVAL(he)); + if (ind < 1) + croak("Bad index while coercing array into hash"); + } else { + ind = AvFILL(av) + 1; + hv_store_ent((HV*)SvRV(*keys), keysv, newSViv(ind), hash); + } + return av_store(av, ind, val); +} + bool avhv_exists_ent(av, keysv, hash) AV *av; diff --git a/global.sym b/global.sym index 1a8dd7f231..27d80c5dc3 100644 --- a/global.sym +++ b/global.sym @@ -303,13 +303,17 @@ append_list apply assertref avhv_delete +avhv_delete_ent avhv_exists +avhv_exists_ent avhv_fetch +avhv_fetch_ent avhv_iterinit avhv_iternext avhv_iternextsv avhv_iterval avhv_store +avhv_store_ent av_clear av_extend av_fake |