summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--av.c26
-rw-r--r--global.sym4
2 files changed, 30 insertions, 0 deletions
diff --git a/av.c b/av.c
index e3d341c361..af3e94e8bc 100644
--- a/av.c
+++ b/av.c
@@ -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