summaryrefslogtreecommitdiff
path: root/av.c
diff options
context:
space:
mode:
authorMalcolm Beattie <mbeattie@sable.ox.ac.uk>1997-05-26 11:38:45 +0000
committerMalcolm Beattie <mbeattie@sable.ox.ac.uk>1997-05-26 11:38:45 +0000
commit5bc6513ddd9360f3cbfa6bf29425e38b658230f5 (patch)
tree5ee77e4046c2720ba400fddad7f9ff89e77b1126 /av.c
parent97fcbf9696d4cdc3d47f383b99d9840ccb39c616 (diff)
downloadperl-5bc6513ddd9360f3cbfa6bf29425e38b658230f5.tar.gz
Add avhv_store_ent. Add missing avhv_* to global.sym.
p4raw-id: //depot/perl@20
Diffstat (limited to 'av.c')
-rw-r--r--av.c26
1 files changed, 26 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;