- if (he) {
- ind = SvIV(HeVAL(he));
- if (ind < 1)
- croak("Bad index while coercing array into hash");
- } else {
- if (!lval)
- return 0;
-
- ind = AvFILL(av) + 1;
- hv_store_ent(keys, keysv, newSViv(ind), 0);
- }
- return av_fetch(av, ind, lval);
-}
-
-SV**
-avhv_store(AV *av, char *key, U32 klen, SV *val, U32 hash)
-{
- SV **indsvp;
- HV *keys = avhv_keys(av);
- I32 ind;
-
- indsvp = hv_fetch(keys, key, klen, FALSE);
- if (indsvp) {
- ind = SvIV(*indsvp);
- if (ind < 1)
- croak("Bad index while coercing array into hash");
- } else {
- ind = AvFILL(av) + 1;
- hv_store(keys, key, klen, newSViv(ind), hash);
- }
- return av_store(av, ind, val);
-}
-
-SV**
-avhv_store_ent(AV *av, SV *keysv, SV *val, U32 hash)
-{
- HV *keys = avhv_keys(av);
- HE *he;
- I32 ind;
-
- he = hv_fetch_ent(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(keys, keysv, newSViv(ind), hash);
- }
- return av_store(av, ind, val);