diff options
author | Ilya Zakharevich <ilya@math.berkeley.edu> | 1998-06-26 19:28:41 -0400 |
---|---|---|
committer | Gurusamy Sarathy <gsar@cpan.org> | 1998-06-29 06:01:35 +0000 |
commit | b3ac6de7f0c7a63b73f1cf3ea9e371470f7d1cb0 (patch) | |
tree | 564cec3756b2fdc36f8885a6017a9b0eed22dca1 /hv.c | |
parent | dde527fc6256d3b4a78a8a6187a9b8048cc76da5 (diff) | |
download | perl-b3ac6de7f0c7a63b73f1cf3ea9e371470f7d1cb0.tar.gz |
added patch for overloading constants, made PERL_OBJECT-aware
Message-Id: <199806270328.XAA21088@monk.mps.ohio-state.edu>
p4raw-id: //depot/perl@1259
Diffstat (limited to 'hv.c')
-rw-r--r-- | hv.c | 39 |
1 files changed, 39 insertions, 0 deletions
@@ -834,6 +834,45 @@ newHV(void) return hv; } +HV * +newHVhv(HV *ohv) +{ + register HV *hv; + register XPVHV* xhv; + STRLEN hv_max = ohv ? HvMAX(ohv) : 0; + STRLEN hv_fill = ohv ? HvFILL(ohv) : 0; + + hv = newHV(); + while (hv_max && hv_max + 1 >= hv_fill * 2) + hv_max = hv_max / 2; /* Is always 2^n-1 */ + ((XPVHV*)SvANY(hv))->xhv_max = hv_max; + if (!hv_fill) + return hv; + +#if 0 + if (!SvRMAGICAL(ohv) || !mg_find((SV*)ohv,'P')) { + /* Quick way ???*/ + } + else +#endif + { + HE *entry; + I32 hv_riter = HvRITER(ohv); /* current root of iterator */ + HE *hv_eiter = HvEITER(ohv); /* current entry of iterator */ + + /* Slow way */ + hv_iterinit(hv); + while (entry = hv_iternext(ohv)) { + hv_store(hv, HeKEY(entry), HeKLEN(entry), + SvREFCNT_inc(HeVAL(entry)), HeHASH(entry)); + } + HvRITER(ohv) = hv_riter; + HvEITER(ohv) = hv_eiter; + } + + return hv; +} + void hv_free_ent(HV *hv, register HE *entry) { |