/* hv.c
*
* Copyright (C) 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
* 2000, 2001, 2002, 2003, 2004, by Larry Wall and others
*
* You may distribute under the terms of either the GNU General Public
* License or the Artistic License, as specified in the README file.
*
*/
/*
* "I sit beside the fire and think of all that I have seen." --Bilbo
*/
/*
=head1 Hash Manipulation Functions
*/
#include "EXTERN.h"
#define PERL_IN_HV_C
#define PERL_HASH_INTERNAL_ACCESS
#include "perl.h"
{
if (!PL_he_root)
more_he();
he = PL_he_root;
return he;
}
STATIC void
{
PL_he_root = p;
}
STATIC void
{
PL_he_root = ++he;
he++;
}
}
#ifdef PURIFY
#else
#endif
{
char *k;
if (flags & HVhek_FREEKEY)
return hek;
}
* for tied hashes */
void
{
while (he) {
}
}
#if defined(USE_ITHREADS)
HE *
{
if (!e)
return Nullhe;
/* look for it in the table first */
if (ret)
return ret;
/* create anew and remember what it is */
char *k;
}
else if (shared)
HeKFLAGS(e));
else
HeKFLAGS(e));
return ret;
}
#endif /* USE_ITHREADS */
static void
const char *msg)
{
if (!(flags & HVhek_FREEKEY)) {
}
else {
/* Need to free saved eventually assign to mortal SV */
/* XXX is this line an error ???: SV *sv = sv_newmortal(); */
}
if (flags & HVhek_UTF8) {
}
}
/* (klen == HEf_SVKEY) is special for MAGICAL hv entries, meaning key slot
* contains an SV* */
/*
=for apidoc hv_store
Stores an SV in a hash. The hash key is specified as C<key> and C<klen> is
the length of the key. The C<hash> parameter is the precomputed hash
value; if it is zero then Perl will compute it. The return value will be
NULL if the operation failed or if the value did not need to be actually
stored within the hash (as in the case of tied hashes). Otherwise it can
be dereferenced to get the original C<SV*>. Note that the caller is
responsible for suitably incrementing the reference count of C<val> before
the call, and decrementing it if the function returned NULL. Effectively
a successful hv_store takes ownership of one reference to C<val>. This is
usually what you want; a newly created SV has a reference count of one, so
if all your code does is create SVs then store them in a hash, hv_store
will own the only reference to the new SV, and your code doesn't need to do
anything further to tidy up. hv_store is not implemented as a call to
hv_store_ent, and does not create a temporary SV for the key, so if your
key data is not already in SV form then use hv_store in preference to
hv_store_ent.
See L<perlguts/"Understanding the Magic of Tied Hashes and Arrays"> for more
information on how to use this function on tied hashes.
=cut
*/
SV**
{
int flags;
if (klen_i32 < 0) {
flags = HVhek_UTF8;
} else {
flags = 0;
}
}
SV**
{
}
/*
=for apidoc hv_store_ent
Stores C<val> in a hash. The hash key is specified as C<key>. The C<hash>
parameter is the precomputed hash value; if it is zero then Perl will
compute it. The return value is the new hash entry so created. It will be
NULL if the operation failed or if the value did not need to be actually
stored within the hash (as in the case of tied hashes). Otherwise the
contents of the return value can be accessed using the C<He?> macros
described here. Note that the caller is responsible for suitably
incrementing the reference count of C<val> before the call, and
decrementing it if the function returned NULL. Effectively a successful
hv_store_ent takes ownership of one reference to C<val>. This is
usually what you want; a newly created SV has a reference count of one, so
if all your code does is create SVs then store them in a hash, hv_store
will own the only reference to the new SV, and your code doesn't need to do
anything further to tidy up. Note that hv_store_ent only reads the C<key>;
unlike C<val> it does not take ownership of it, so maintaining the correct
reference count on C<key> is entirely the caller's responsibility. hv_store
is not implemented as a call to hv_store_ent, and does not create a temporary
SV for the key, so if your key data is not already in SV form then use
hv_store in preference to hv_store_ent.
See L<perlguts/"Understanding the Magic of Tied Hashes and Arrays"> for more
information on how to use this function on tied hashes.
=cut
*/
HE *
{
}
/*
=for apidoc hv_exists
Returns a boolean indicating whether the specified hash key exists. The
C<klen> is the length of the key.
=cut
*/
bool
{
int flags;
if (klen_i32 < 0) {
flags = HVhek_UTF8;
} else {
flags = 0;
}
}
/*
=for apidoc hv_fetch
Returns the SV which corresponds to the specified key in the hash. The
C<klen> is the length of the key. If C<lval> is set then the fetch will be
part of a store. Check that the return value is non-null before
dereferencing it to an C<SV*>.
See L<perlguts/"Understanding the Magic of Tied Hashes and Arrays"> for more
information on how to use this function on tied hashes.
=cut
*/
SV**
{
int flags;
if (klen_i32 < 0) {
flags = HVhek_UTF8;
} else {
flags = 0;
}
Nullsv, 0);
}
/*
=for apidoc hv_exists_ent
Returns a boolean indicating whether the specified hash key exists. C<hash>
can be a valid precomputed hash value, or 0 to ask for it to be
computed.
=cut
*/
bool
{
}
/* returns an HE * structure with the all fields set */
/* note that hent_val will be a mortal sv for MAGICAL hashes */
/*
=for apidoc hv_fetch_ent
Returns the hash entry which corresponds to the specified key in the hash.
C<hash> must be a valid precomputed hash number for the given C<key>, or 0
if you want the function to compute it. IF C<lval> is set then the fetch
will be part of a store. Make sure the return value is non-null before
accessing it. The return value when C<tb> is a tied hash is a pointer to a
static location, so be sure to make a copy of the structure if you need to
store it somewhere.
See L<perlguts/"Understanding the Magic of Tied Hashes and Arrays"> for more
information on how to use this function on tied hashes.
=cut
*/
HE *
{
}
{
bool is_utf8;
int masked_flags;
if (!hv)
return 0;
if (keysv) {
if (flags & HVhek_FREEKEY)
flags = 0;
} else {
}
{
sv = sv_newmortal();
HV_FETCH_JUST_SV is true. */
if (!keysv) {
if (is_utf8) {
}
} else {
}
if (entry)
else {
char *k;
}
/* so we can free entry when freeing sv */
/* XXX remove at some point? */
if (flags & HVhek_FREEKEY)
return entry;
}
#ifdef ENV_IS_CASELESS
U32 i;
for (i = 0; i < klen; ++i)
/* Would be nice if we had a routine to do the
copy and upercase in a single pass through. */
/* Note that this fetch is for nkey (the uppercased
key) whereas the store is for key (the original) */
HVhek_FREEKEY, /* free nkey */
0 /* non-LVAL fetch */,
Nullsv /* no value */,
0 /* compute hash */);
/* This call will free key if necessary.
Do it this way to encourage compiler to tail
call optimise. */
} else {
if (flags & HVhek_FREEKEY)
}
return entry;
}
}
#endif
} /* ISFETCH */
/* I don't understand why hv_exists_ent has svret and sv,
whereas hv_exists only had one. */
svret = sv_newmortal();
sv = sv_newmortal();
if (!keysv) {
} else {
}
} else {
}
if (flags & HVhek_FREEKEY)
/* This cast somewhat evil, but I'm merely using NULL/
not NULL to return the boolean exists.
And I know hv is not NULL. */
}
#ifdef ENV_IS_CASELESS
/* XXX This code isn't UTF8 clean. */
/* Will need to free this, so set FREEKEY flag. */
is_utf8 = 0;
hash = 0;
if (flags & HVhek_FREEKEY) {
}
flags |= HVhek_FREEKEY;
}
#endif
} /* ISEXISTS */
else if (action & HV_FETCH_ISSTORE) {
bool needs_copy;
bool needs_store;
if (needs_copy) {
if (!keysv) {
}
if (PL_tainting)
} else {
}
if (flags & HVhek_FREEKEY)
return Nullhe;
}
#ifdef ENV_IS_CASELESS
/* XXX This code isn't UTF8 clean. */
/* Will need to free this, so set FREEKEY flag. */
is_utf8 = 0;
hash = 0;
if (flags & HVhek_FREEKEY) {
}
flags |= HVhek_FREEKEY;
}
#endif
}
} /* ISSTORE */
} /* SvMAGICAL */
#ifdef DYNAMIC_ENV_FETCH /* if it's an %ENV lookup, we may get it on the fly */
#endif
)
char);
#ifdef DYNAMIC_ENV_FETCH
else if (action & HV_FETCH_ISEXISTS) {
/* for an %ENV exists, if we do an insert it's by a recursive
store call, so avoid creating HvARRAY(hv) right now. */
}
#endif
else {
/* XXX remove at some point? */
if (flags & HVhek_FREEKEY)
return 0;
}
}
if (is_utf8) {
if (is_utf8)
flags |= HVhek_UTF8;
else
flags &= ~HVhek_UTF8;
if (flags & HVhek_FREEKEY)
}
}
/* We don't have a pointer to the hv, so we have to replicate the
flag into every HEK, so that hv_iterkeysv can see it. */
/* And yes, you do need this even though you are not "storing" because
you can flip the flags below if doing an lval lookup. (And that
was put in to give the semantics Andreas was expecting.) */
flags |= HVhek_REHASH;
} else if (!hash) {
/* Not enough shared hash key scalars around to make this worthwhile
(about 4% slowdown in perlbench with this in)
if (keysv && (SvIsCOW_shared_hash(keysv))) {
hash = SvUVX(keysv);
} else
*/
{
}
}
n_links = 0;
#ifdef DYNAMIC_ENV_FETCH
else
#endif
{
/* entry = (HvARRAY(hv))[hash & (I32) HvMAX(hv)]; */
}
continue;
continue;
continue;
continue;
/* We match if HVhek_UTF8 bit in our flags and hash key's
match. But if entry was set previously with HVhek_WASUTF8
and key now doesn't (or vice versa) then we should change
the key's flag, as this is assignment. */
if (HvSHAREKEYS(hv)) {
/* Need to swap the key we have for a key with the flags we
need. As keys are shared we can't just write to the
flag, so we share the new one, unshare the old one. */
}
else
if (masked_flags & HVhek_ENABLEHVKFLAGS)
}
/* yes, can store into placeholder slot */
if (action & HV_FETCH_LVALUE) {
/* This preserves behaviour with the old hv_fetch
implementation which at this point would bail out
with a break; (at "if we find a placeholder, we
pretend we haven't found anything")
That break mean that if a placeholder were found, it
caused a call into hv_store, which in turn would
check magic, and if there is no magic end up pretty
much back at this point (in hv_store's code). */
break;
}
/* LVAL fetch which actaully needs a store. */
xhv->xhv_placeholders--;
} else {
/* store */
if (val != &PL_sv_placeholder)
xhv->xhv_placeholders--;
}
} else if (action & HV_FETCH_ISSTORE) {
}
/* if we find a placeholder, we pretend we haven't found
anything */
break;
}
if (flags & HVhek_FREEKEY)
return entry;
}
#ifdef DYNAMIC_ENV_FETCH /* %ENV lookup? If so, try to fetch the value now */
if (!(action & HV_FETCH_ISSTORE)
unsigned long len;
if (env) {
hash);
}
}
#endif
);
}
/* Not doing some form of store, so return failure. */
if (flags & HVhek_FREEKEY)
return 0;
}
if (action & HV_FETCH_LVALUE) {
/* At this point the old hv_fetch code would call to hv_store,
which in turn might do some tied magic. So we need to make that
magic check happen. */
/* gonna assign to this, so it better be there */
/* XXX Surely that could leak if the fetch-was-store fails?
Just like the hv_fetch. */
}
}
/* Welcome to hv_store... */
/* Not sure if we can get here. I think the only case of oentry being
NULL is for %ENV with dynamic env fetch. But that should disappear
with magic in the previous code. */
char);
}
/* share_hek_flags will do the free for us. This might be considered
bad API design. */
if (HvSHAREKEYS(hv))
else /* gotta do the real thing */
if (val == &PL_sv_placeholder)
xhv->xhv_placeholders++;
if (masked_flags & HVhek_ENABLEHVKFLAGS)
if (!n_links) { /* initial entry? */
/* Use only the old HvKEYS(hv) > HvMAX(hv) condition to limit bucket
splits on a rehashed hash, as we're not going to split it again,
and if someone is lucky (evil) enough to get all the keys in one
list they could exhaust our memory as we repeatedly double the
number of buckets on every entry. Linear search feels a less worse
thing to do. */
}
return entry;
}
STATIC void
{
*needs_copy = FALSE;
*needs_store = TRUE;
while (mg) {
*needs_copy = TRUE;
case PERL_MAGIC_tied:
case PERL_MAGIC_sig:
*needs_store = FALSE;
}
}
}
}
/*
=for apidoc hv_scalar
Evaluates the hash in scalar context and returns the result. Handles magic when the hash is tied.
=cut
*/
SV *
{
return sv;
}
sv = sv_newmortal();
else
return sv;
}
/*
=for apidoc hv_delete
hash and returned to the caller. The C<klen> is the length of the key.
The C<flags> value will normally be zero; if set to G_DISCARD then NULL
will be returned.
=cut
*/
SV *
{
int k_flags = 0;
if (klen_i32 < 0) {
k_flags |= HVhek_UTF8;
} else {
}
}
/*
=for apidoc hv_delete_ent
hash and returned to the caller. The C<flags> value will normally be zero;
if set to G_DISCARD then NULL will be returned. C<hash> can be a valid
precomputed hash value, or 0 to ask for it to be computed.
=cut
*/
SV *
{
}
{
register I32 i;
bool is_utf8;
int masked_flags;
if (!hv)
return Nullsv;
if (keysv) {
if (k_flags & HVhek_FREEKEY)
k_flags = 0;
} else {
}
if (SvRMAGICAL(hv)) {
bool needs_copy;
bool needs_store;
if (needs_copy) {
if (sv) {
}
if (!needs_store) {
/* No longer an element */
return sv;
}
return Nullsv; /* element cannot be deleted */
}
#ifdef ENV_IS_CASELESS
/* XXX This code isn't UTF8 clean. */
if (k_flags & HVhek_FREEKEY) {
}
is_utf8 = 0;
k_flags = 0;
hash = 0;
}
#endif
}
}
}
return Nullsv;
if (is_utf8) {
if (is_utf8)
k_flags |= HVhek_UTF8;
else
k_flags &= ~HVhek_UTF8;
if (k_flags & HVhek_FREEKEY) {
/* This shouldn't happen if our caller does what we expect,
but strictly the API allows it. */
}
}
}
} else if (!hash) {
/* Not enough shared hash key scalars around to make this worthwhile
(about 4% slowdown in perlbench with this in)
if (keysv && (SvIsCOW_shared_hash(keysv))) {
hash = SvUVX(keysv);
} else
*/
{
}
}
/* oentry = &(HvARRAY(hv))[hash & (I32) HvMAX(hv)]; */
i = 1;
continue;
continue;
continue;
continue;
/* if placeholder is here, it's already been deleted.... */
{
if (k_flags & HVhek_FREEKEY)
return Nullsv;
}
);
}
if (k_flags & HVhek_FREEKEY)
else {
}
/*
* If a restricted hash, rather than really deleting the entry, put
* a placeholder there. This marks the key as being "approved", so
* we can still access via not-really-existing key without raising
* an error.
*/
if (SvREADONLY(hv)) {
/* We'll be saving this slot, so the number of allocated keys
* doesn't go down, but the number placeholders goes up */
} else {
if (i && !*oentry)
else
}
return sv;
}
if (SvREADONLY(hv)) {
);
}
if (k_flags & HVhek_FREEKEY)
return Nullsv;
}
STATIC void
{
register I32 i;
int longest_chain = 0;
int was_shared;
/*PerlIO_printf(PerlIO_stderr(), "hsplit called for %p which had %d\n",
hv, (int) oldsize);*/
/* Can make this clear any placeholders first for non-restricted hashes,
even though Storable rebuilds restricted hashes by putting in all the
placeholders (first) before turning on the readonly flag, because
Storable always pre-splits the hash. */
}
PL_nomemok = TRUE;
#if defined(STRANGE_MALLOC) || defined(MYMALLOC)
if (!a) {
PL_nomemok = FALSE;
return;
}
#else
if (!a) {
PL_nomemok = FALSE;
return;
}
if (oldsize >= 64) {
}
else
#endif
PL_nomemok = FALSE;
int left_length = 0;
int right_length = 0;
if (!*aep) /* non-existent */
continue;
if (!*bep)
right_length++;
continue;
}
else {
left_length++;
}
}
if (!*aep) /* everything moved */
/* I think we don't actually need to keep track of the longest length,
merely flag if anything is too long. But for the moment while
developing this code I'll track it. */
if (left_length > longest_chain)
if (right_length > longest_chain)
}
/* Pick your policy for "hashing isn't working" here: */
return;
}
/* Urg. Someone is doing something nasty to the string table.
Can't win. */
return;
}
/* Awooga. Awooga. Pathological data. */
/*PerlIO_printf(PerlIO_stderr(), "%p %d of %d with %d/%d buckets\n", hv,
longest_chain, HvTOTALKEYS(hv), HvFILL(hv), 1+HvMAX(hv));*/
++newsize;
while (entry) {
/* We're going to trash this HE's next pointer when we chain it
into the new hash below, so store where we go next. */
/* Rehash it */
if (was_shared) {
/* Unshare it. */
} else {
/* Not shared, so simply write the new hash in. */
}
/*PerlIO_printf(PerlIO_stderr(), "%d ", HeKFLAGS(entry));*/
/*PerlIO_printf(PerlIO_stderr(), "%d\n", HeKFLAGS(entry));*/
/* Copy oentry to the correct new chain. */
if (!*bep)
}
}
}
void
{
register I32 i;
register I32 j;
register char *a;
return;
}
newsize *= 2;
return; /* overflow detection */
if (a) {
PL_nomemok = TRUE;
#if defined(STRANGE_MALLOC) || defined(MYMALLOC)
if (!a) {
PL_nomemok = FALSE;
return;
}
#else
if (!a) {
PL_nomemok = FALSE;
return;
}
if (oldsize >= 64) {
}
else
#endif
PL_nomemok = FALSE;
}
else {
}
return;
if (!*aep) /* non-existent */
continue;
j -= i;
continue;
}
else
}
if (!*aep) /* everything moved */
}
}
/*
=for apidoc newHV
Creates a new HV. The reference count is set to 1.
=cut
*/
HV *
{
#ifndef NODEFAULT_SHAREKEYS
#endif
return hv;
}
HV *
{
return hv;
/* It's an ordinary hash, so copy it fast. AMS 20010804 */
STRLEN i;
char *a;
/* In each bucket... */
for (i = 0; i <= hv_max; i++) {
if (!oent) {
continue;
}
/* Copy the linked list of entries. */
if (prev)
else
}
}
}
else {
/* Iterate over ohv, copying keys and values one at a time. */
/* Can we use fewer buckets? (hv_max is always 2^n-1) */
}
}
return hv;
}
void
{
if (!entry)
return;
PL_sub_generation++; /* may be deletion of method from stash */
}
else if (HvSHAREKEYS(hv))
else
}
void
{
if (!entry)
return;
PL_sub_generation++; /* may be deletion of method from stash */
}
else if (HvSHAREKEYS(hv))
else
}
/*
=for apidoc hv_clear
Clears a hash, making it empty.
=cut
*/
void
{
if (!hv)
return;
/* restricted hash: convert all keys to placeholders */
I32 i;
/* not already placeholder */
keysv);
}
}
}
}
goto reset;
}
if (SvRMAGICAL(hv))
}
/*
=for apidoc hv_clear_placeholders
Clears any placeholders from a hash. If a restricted hash has any of its keys
marked as readonly and the key is subsequently deleted, the key is not actually
deleted but is marked by assigning it a value of &PL_sv_placeholder. This tags
it so it will be ignored by future operations such as iterating over the hash,
but will still allow the hash to have a value reaasigned to the key at some
future point. This function clears any such placeholder keys from the hash.
See Hash::Util::lock_keys() for an example of its use.
=cut
*/
void
{
if (items == 0)
return;
do {
/* Loop down the linked list heads */
if (!entry)
continue;
else
if (--items == 0) {
/* Finished. */
HvPLACEHOLDERS(hv) = 0;
return;
}
} else {
first = 0;
}
}
} while (--i >= 0);
/* You can't get here, hence assertion should always fail. */
assert (0);
}
STATIC void
{
if (!hv)
return;
return;
riter = 0;
/* make everyone else think the array is empty, so that the destructors
* called for freed entries can't recusively mess with us */
for (;;) {
if (entry) {
}
if (!entry) {
break;
}
}
(void)hv_iterinit(hv);
}
/*
=for apidoc hv_undef
Undefines the hash.
=cut
*/
void
{
if (!hv)
return;
if(PL_stashcache)
}
if (SvRMAGICAL(hv))
}
/*
=for apidoc hv_iterinit
Prepares a starting point to traverse a hash table. Returns the number of
keys in the hash (i.e. the same as C<HvKEYS(tb)>). The return value is
currently only meaningful for hashes without tie magic.
NOTE: Before version 5.004_65, C<hv_iterinit> used to return the number of
hash buckets that happen to be in use. If you still need that esoteric
value, you can get it through the macro C<HvFILL(tb)>.
=cut
*/
{
if (!hv)
}
/* used to be xhv->xhv_fill before 5.004_65 */
return XHvTOTALKEYS(xhv);
}
/*
=for apidoc hv_iternext
Returns entries from a hash iterator. See C<hv_iterinit>.
You may call C<hv_delete> or C<hv_delete_ent> on the hash entry that the
iterator currently points to, without losing your place or invalidating your
iterator. Note that in this case the current entry is deleted from the hash
with your iterator holding the last reference to it. Your iterator is flagged
to free the entry on the next call to C<hv_iternext>, so you must not discard
your iterator immediately else the entry will leak - call C<hv_iternext> to
trigger the resource deallocation.
=cut
*/
HE *
{
return hv_iternext_flags(hv, 0);
}
/*
=for apidoc hv_iternext_flags
Returns entries from a hash iterator. See C<hv_iterinit> and C<hv_iternext>.
The C<flags> value will normally be zero; if HV_ITERNEXT_WANTPLACEHOLDERS is
set the placeholders keys (for restricted hashes) will be returned in addition
to normal keys. By default placeholders are automatically skipped over.
Currently a placeholder is implemented with a value that is
C<&Perl_sv_placeholder>. Note that the implementation of placeholders and
restricted hashes may change, and the implementation currently is
insufficiently abstracted for any change to be tidy.
=cut
*/
HE *
{
if (!hv)
if (entry) {
}
else {
char *k;
/* one HE per MAGICAL hash */
}
/* force key to stay around until next time */
return entry; /* beware, hent_val is not set */
}
}
#ifdef DYNAMIC_ENV_FETCH /* set up %ENV for iteration */
#endif
char);
/* At start of hash, entry is NULL. */
if (entry)
{
if (!(flags & HV_ITERNEXT_WANTPLACEHOLDERS)) {
/*
* Skip past any placeholders -- don't want to include them in
* any iteration.
*/
}
}
}
while (!entry) {
/* OK. Come to the end of the current list. Grab the next one. */
/* There is no next one. End of the hash. */
break;
}
/* entry = (HvARRAY(hv))[HvRITER(hv)]; */
if (!(flags & HV_ITERNEXT_WANTPLACEHOLDERS)) {
/* If we have an entry, but it's a placeholder, don't count it.
Try the next. */
}
/* Will loop again if this linked list starts NULL
(for HV_ITERNEXT_WANTPLACEHOLDERS)
or if we run through it and find only placeholders. */
}
}
/*if (HvREHASH(hv) && entry && !HeKREHASH(entry))
PerlIO_printf(PerlIO_stderr(), "Awooga %p %p\n", hv, entry);*/
return entry;
}
/*
=for apidoc hv_iterkey
Returns the key from the current position of the hash iterator. See
C<hv_iterinit>.
=cut
*/
char *
{
return p;
}
else {
}
}
/* unlike hv_iterval(), this always returns a mortal copy of the key */
/*
=for apidoc hv_iterkeysv
Returns the key as an C<SV*> from the current position of the hash
iterator. The return value will always be a mortal copy of the key. Also
see C<hv_iterinit>.
=cut
*/
SV *
{
if (flags & HVhek_WASUTF8) {
/* Trouble :-)
Andreas would like keys he put in as utf8 to come back as utf8
*/
} else if (flags & HVhek_REHASH) {
/* We don't have a pointer to the hv, so we have to replicate the
flag into every HEK. This hv is using custom a hasing
algorithm. Hence we can't return a shared string scalar, as
that would contain the (wrong) hash value, and might get passed
into an hv routine with a regular hash */
} else {
}
return sv_2mortal(sv);
}
}
/*
=for apidoc hv_iterval
Returns the value from the current position of the hash iterator. See
C<hv_iterkey>.
=cut
*/
SV *
{
if (SvRMAGICAL(hv)) {
return sv;
}
}
}
/*
=for apidoc hv_iternextsv
Performs an C<hv_iternext>, C<hv_iterkey>, and C<hv_iterval> in one
operation.
=cut
*/
SV *
{
return NULL;
}
/*
=for apidoc hv_magic
Adds magic to a hash. See C<sv_magic>.
=cut
*/
void
{
}
#if 0 /* use the macro from hv.h instead */
char*
{
}
#endif
/* possibly free a shared string if no one has access to it
* len and hash must both be valid for str.
*/
void
{
}
void
{
}
/* possibly free a shared string if no one has access to it
hek if non-NULL takes priority over the other 3, else str, len and hash
are used. If so, len and hash must both be valid for str.
*/
STATIC void
{
register I32 i = 1;
int k_flags = 0;
if (hek) {
} else if (len < 0) {
/* See the note in hv_fetch(). --jhi */
if (is_utf8)
}
/* what follows is the moral equivalent of:
if ((Svp = hv_fetch(PL_strtab, tmpsv, FALSE, hash))) {
if (--*Svp == Nullsv)
hv_delete(PL_strtab, str, len, G_DISCARD, hash);
} */
/* assert(xhv_array != 0) */
/* oentry = &(HvARRAY(hv))[hash & (I32) HvMAX(hv)]; */
if (hek) {
continue;
found = 1;
break;
}
} else {
continue;
continue;
continue;
continue;
found = 1;
break;
}
}
if (found) {
if (i && !*oentry)
}
}
"Attempt to free non-existent shared string '%s'%s",
if (k_flags & HVhek_FREEKEY)
}
/* get a (constant) string ptr from the global string table
* string will get added if it is not already there.
* len and hash must both be valid for str.
*/
HEK *
{
int flags = 0;
if (len < 0) {
/* See the note in hv_fetch(). --jhi */
/* If we were able to downgrade here, then than means that we were passed
in a key which only had chars 0-255, but was utf8 encoded. */
if (is_utf8)
flags = HVhek_UTF8;
/* If we found we were able to downgrade the string to bytes, then
we should flag that it needs upgrading on keys or each. Also flag
that we need share_hek_flags to free the string. */
}
}
{
register I32 i = 1;
/* what follows is the moral equivalent of:
if (!(Svp = hv_fetch(PL_strtab, str, len, FALSE)))
hv_store(PL_strtab, str, len, Nullsv, hash);
Can't rehash the shared string table, so not sure if it's worth
counting the number of entries in the linked list
*/
/* assert(xhv_array != 0) */
/* oentry = &(HvARRAY(hv))[hash & (I32) HvMAX(hv)]; */
continue;
continue;
continue;
continue;
found = 1;
break;
}
if (!found) {
if (i) { /* initial entry? */
}
}
if (flags & HVhek_FREEKEY)
}