Ruby: hash.c File Reference

Ruby 3.0.5p211 (2022-11-24 revision ba5cf0f7c52d4d35cc6a173c89eda98ceffa2dcf)

Data Structures | Macros | Typedefs | Functions | Variables
hash.c File Reference
`#include "ruby/internal/config.h"`
`#include <errno.h>`
`#include "debug_counter.h"`
`#include "id.h"`
`#include "internal.h"`
`#include "internal/array.h"`
`#include "internal/bignum.h"`
`#include "internal/class.h"`
`#include "internal/cont.h"`
`#include "internal/error.h"`
`#include "internal/hash.h"`
`#include "internal/object.h"`
`#include "internal/proc.h"`
`#include "internal/symbol.h"`
`#include "internal/time.h"`
`#include "internal/vm.h"`
`#include "probes.h"`
`#include "ruby/st.h"`
`#include "ruby/util.h"`
`#include "ruby_assert.h"`
`#include "symbol.h"`
`#include "transient_heap.h"`

Go to the source code of this file.

## Data Structures
struct | ar_table_pair_struct
struct | ar_table_struct
struct | functor
struct | foreach_safe_arg
struct | hash_foreach_arg
struct | update_callback_arg
struct | update_arg
struct | rehash_arg
struct | shift_var
struct | transform_keys_args
struct | equal_data
struct | update_func_arg
struct | reset_hash_type_arg

## Macros
#define | HASH_DEBUG 0
#define | HAS_EXTRA_STATES(hash, klass)
#define | SET_DEFAULT(hash, ifnone)
#define | SET_PROC_DEFAULT(hash, proc) set_proc_default(hash, proc)
#define | COPY_DEFAULT(hash, hash2) copy_default(RHASH(hash), RHASH(hash2))
#define | st_index_hash(index) key64_hash(rb_hash_start(index), prime2)
#define | rb_ident_cmp st_numcmp
#define | identhash rb_hashtype_ident
#define | RHASH_AR_TABLE_MAX_BOUND RHASH_AR_TABLE_MAX_SIZE
#define | RHASH_AR_TABLE_REF(hash, n) (&RHASH_AR_TABLE(hash)->pairs[n])
#define | RHASH_AR_CLEARED_HINT 0xff
#define | RHASH_AR_TABLE_SIZE(h)
#define | RHASH_AR_TABLE_BOUND_RAW(h)
#define | RHASH_AR_TABLE_BOUND(h)
#define | RHASH_ST_TABLE_SET(h, s) rb_hash_st_table_set(h, s)
#define | RHASH_TYPE(hash) (RHASH_AR_TABLE_P(hash) ? &objhash : RHASH_ST_TABLE(hash)->type)
#define | HASH_ASSERT(expr) RUBY_ASSERT_MESG_WHEN(HASH_DEBUG, expr, #expr)
#define | hash_verify(h) ((void)0)
#define | RHASH_SET_ST_FLAG(h) FL_SET_RAW(h, RHASH_ST_TABLE_FLAG)
#define | RHASH_UNSET_ST_FLAG(h) FL_UNSET_RAW(h, RHASH_ST_TABLE_FLAG)
#define | RHASH_AR_TABLE_SIZE_INC(h) HASH_AR_TABLE_SIZE_ADD(h, 1)
#define | NOINSERT_UPDATE_CALLBACK(func)
#define | UPDATE_CALLBACK(iter_lev, func) ((iter_lev) > 0 ? func##_noinsert : func##_insert)
#define | RHASH_UPDATE_ITER(h, iter_lev, key, func, a)
#define | RHASH_UPDATE(hash, key, func, arg) RHASH_UPDATE_ITER(hash, RHASH_ITER_LEV(hash), key, func, arg)
#define | to_hash rb_to_hash_type
#define | GET_ENVIRON(e) (e)
#define | FREE_ENVIRON(e)
#define | ENVMATCH(n1, n2) (strcmp((n1), (n2)) == 0)
#define | ENVNMATCH(s1, s2, n) (memcmp((s1), (s2), (n)) == 0)
#define | get_env_ptr(var, val) (var = get_env_cstr(val, #var))
#define | env_name(s) env_name(&(s))

## Typedefs
typedef st_index_t | st_hash_t
typedef struct ar_table_pair_struct | ar_table_pair
typedef struct ar_table_struct | ar_table
typedef int | st_foreach_func(st_data_t, st_data_t, st_data_t)
typedef int | rb_foreach_func(VALUE, VALUE, VALUE)
typedef int(* | tbl_update_func) (st_data_t *, st_data_t *, st_data_t, int)

## Functions
VALUE | rb_hash_freeze (VALUE hash)
VALUE | rb_hash_set_ifnone (VALUE hash, VALUE ifnone)
VALUE | rb_hash (VALUE obj)
long | rb_dbl_long_hash (double d)
size_t | rb_hash_ar_table_size (void)
int | rb_hash_ar_table_p (VALUE hash)
ar_table * | rb_hash_ar_table (VALUE hash)
st_table * | rb_hash_st_table (VALUE hash)
void | rb_hash_st_table_set (VALUE hash, st_table *st)
void | st_foreach_safe (st_table *table, st_foreach_func *func, st_data_t a)
void | rb_ivar_set_internal (VALUE obj, ID id, VALUE val)
int | rb_hash_stlike_foreach (VALUE hash, st_foreach_callback_func *func, st_data_t arg)
int | rb_hash_stlike_foreach_with_replace (VALUE hash, st_foreach_check_callback_func *func, st_update_callback_func *replace, st_data_t arg)
void | rb_hash_foreach (VALUE hash, rb_foreach_func *func, VALUE farg)
VALUE | rb_hash_new (void)
VALUE | rb_hash_new_with_size (st_index_t size)
VALUE | rb_hash_dup (VALUE hash)
VALUE | rb_hash_resurrect (VALUE hash)
struct st_table * | rb_hash_tbl_raw (VALUE hash, const char *file, int line)
struct st_table * | rb_hash_tbl (VALUE hash, const char *file, int line)
int | rb_hash_stlike_update (VALUE hash, st_data_t key, st_update_callback_func *func, st_data_t arg)
VALUE | rb_to_hash_type (VALUE hash)
VALUE | rb_check_hash_type (VALUE hash)
VALUE | rb_hash_rehash (VALUE hash)
VALUE | rb_hash_default_value (VALUE hash, VALUE key)
int | rb_hash_stlike_lookup (VALUE hash, st_data_t key, st_data_t *pval)
VALUE | rb_hash_aref (VALUE hash, VALUE key)
VALUE | rb_hash_lookup2 (VALUE hash, VALUE key, VALUE def)
VALUE | rb_hash_lookup (VALUE hash, VALUE key)
VALUE | rb_hash_fetch (VALUE hash, VALUE key)
VALUE | rb_hash_set_default_proc (VALUE hash, VALUE proc)
int | rb_hash_stlike_delete (VALUE hash, st_data_t *pkey, st_data_t *pval)
VALUE | rb_hash_delete_entry (VALUE hash, VALUE key)
VALUE | rb_hash_delete (VALUE hash, VALUE key)
VALUE | rb_hash_delete_if (VALUE hash)
VALUE | rb_hash_reject_bang (VALUE hash)
VALUE | rb_hash_reject (VALUE hash)
VALUE | rb_hash_values_at (int argc, VALUE *argv, VALUE hash)
VALUE | rb_hash_clear (VALUE hash)
VALUE | rb_hash_key_str (VALUE key)
VALUE | rb_hash_aset (VALUE hash, VALUE key, VALUE val)
VALUE | rb_hash_size (VALUE hash)
size_t | rb_hash_size_num (VALUE hash)
VALUE | rb_hash_set_pair (VALUE hash, VALUE arg)
VALUE | rb_hash_keys (VALUE hash)
VALUE | rb_hash_values (VALUE hash)
VALUE | rb_hash_has_key (VALUE hash, VALUE key)
VALUE | rb_hash_update_by (VALUE hash1, VALUE hash2, rb_hash_update_func *func)
VALUE | rb_hash_assoc (VALUE hash, VALUE key)
VALUE | rb_hash_rassoc (VALUE hash, VALUE obj)
VALUE | rb_hash_compare_by_id_p (VALUE hash)
VALUE | rb_ident_hash_new (void)
st_table * | rb_init_identtable (void)
int | rb_hash_add_new_element (VALUE hash, VALUE key, VALUE val)
void | rb_hash_bulk_insert (long argc, const VALUE *argv, VALUE hash)
int | rb_env_path_tainted (void)
void | ruby_setenv (const char *name, const char *value)
void | ruby_unsetenv (const char *name)
VALUE | rb_env_clear (void)
void | Init_Hash (void)

## Variables
VALUE | rb_cHash
const struct st_hash_type | rb_hashtype_ident
char ** | environ

## Macro Definition Documentation

## ◆ COPY_DEFAULT

#define COPY_DEFAULT | ( |  | hash,
|  |  | hash2
| ) |  | copy_default(RHASH(hash), RHASH(hash2))

Definition at line 66 of file hash.c.

## ◆ env_name

#define env_name | ( |  | s | ) | env_name(&(s))

Definition at line 4905 of file hash.c.

## ◆ ENVMATCH

#define ENVMATCH | ( |  | n1,
|  |  | n2
| ) |  | (strcmp((n1), (n2)) == 0)

Definition at line 4825 of file hash.c.

## ◆ ENVNMATCH

#define ENVNMATCH | ( |  | s1,
|  |  | s2,
|  |  | n
| ) |  | (memcmp((s1), (s2), (n)) == 0)

Definition at line 4826 of file hash.c.

## ◆ FREE_ENVIRON

#define FREE_ENVIRON | ( |  | e | ) |

Definition at line 4819 of file hash.c.

## ◆ get_env_ptr

#define get_env_ptr | ( |  | var,
|  |  | val
| ) |  | (var = get_env_cstr(val, #var))

Definition at line 4893 of file hash.c.

## ◆ GET_ENVIRON

#define GET_ENVIRON | ( |  | e | ) | (e)

Definition at line 4818 of file hash.c.

## ◆ HAS_EXTRA_STATES

#define HAS_EXTRA_STATES | ( |  | hash,
|  |  | klass
| ) |  |

Value:
( \
((klass = has_extra_methods(rb_obj_class(hash))) != 0) || \
FL_TEST((hash), FL_EXIVAR|RHASH_PROC_DEFAULT) || \
!NIL_P(RHASH_IFNONE(hash)))
FL_EXIVAR
#define FL_EXIVAR
Definition: fl_type.h:58
rb_obj_class
VALUE rb_obj_class(VALUE)
Definition: object.c:245
RHASH_PROC_DEFAULT
@ RHASH_PROC_DEFAULT
Definition: hash.h:25
RHASH_IFNONE
#define RHASH_IFNONE(h)
Definition: rhash.h:49
NIL_P
#define NIL_P
Definition: special_consts.h:46

Definition at line 55 of file hash.c.

## ◆ HASH_ASSERT

#define HASH_ASSERT | ( |  | expr | ) | RUBY_ASSERT_MESG_WHEN(HASH_DEBUG, expr, #expr)

Definition at line 449 of file hash.c.

## ◆ HASH_DEBUG

#define HASH_DEBUG 0

Definition at line 48 of file hash.c.

## ◆ hash_verify

#define hash_verify | ( |  | h | ) | ((void)0)

Definition at line 526 of file hash.c.

## ◆ identhash

#define identhash rb_hashtype_ident

Definition at line 335 of file hash.c.

## ◆ NOINSERT_UPDATE_CALLBACK

#define NOINSERT_UPDATE_CALLBACK | ( |  | func | ) |

Value:
static int \
func##_noinsert(st_data_t *key, st_data_t *val, st_data_t arg, int existing) \
{ \
if (!existing) no_new_key(); \
return func(key, val, (struct update_arg *)arg, existing); \
} \
\
static int \
func##_insert(st_data_t *key, st_data_t *val, st_data_t arg, int existing) \
{ \
return func(key, val, (struct update_arg *)arg, existing); \
}
key
key
Definition: openssl_missing.h:185
st_data_t
unsigned long st_data_t
Definition: st.h:22
update_arg
Definition: hash.c:1647

Definition at line 1633 of file hash.c.

## ◆ rb_ident_cmp

#define rb_ident_cmp st_numcmp

Definition at line 316 of file hash.c.

## ◆ RHASH_AR_CLEARED_HINT

#define RHASH_AR_CLEARED_HINT 0xff

Definition at line 356 of file hash.c.

## ◆ RHASH_AR_TABLE_BOUND

#define RHASH_AR_TABLE_BOUND | ( |  | h | ) |

Value:
(HASH_ASSERT(RHASH_AR_TABLE_P(h)), \
RHASH_AR_TABLE_BOUND_RAW(h))
HASH_ASSERT
#define HASH_ASSERT(expr)
Definition: hash.c:449

Definition at line 443 of file hash.c.

## ◆ RHASH_AR_TABLE_BOUND_RAW

#define RHASH_AR_TABLE_BOUND_RAW | ( |  | h | ) |

Value:
((unsigned int)((RBASIC(h)->flags >> RHASH_AR_TABLE_BOUND_SHIFT) & \
(RHASH_AR_TABLE_BOUND_MASK >> RHASH_AR_TABLE_BOUND_SHIFT)))
RHASH_AR_TABLE_BOUND_SHIFT
@ RHASH_AR_TABLE_BOUND_SHIFT
Definition: hash.h:30
RHASH_AR_TABLE_BOUND_MASK
@ RHASH_AR_TABLE_BOUND_MASK
Definition: hash.h:29
int
typedef int(ZCALLBACK *close_file_func) OF((voidpf opaque
RBASIC
#define RBASIC(obj)
Definition: rbasic.h:34

Definition at line 439 of file hash.c.

## ◆ RHASH_AR_TABLE_MAX_BOUND

#define RHASH_AR_TABLE_MAX_BOUND RHASH_AR_TABLE_MAX_SIZE

Definition at line 353 of file hash.c.

## ◆ RHASH_AR_TABLE_REF

#define RHASH_AR_TABLE_REF | ( |  | hash,
|  |  | n
| ) |  | (&RHASH_AR_TABLE(hash)->pairs[n])

Definition at line 355 of file hash.c.

## ◆ RHASH_AR_TABLE_SIZE

#define RHASH_AR_TABLE_SIZE | ( |  | h | ) |

Value:
(HASH_ASSERT(RHASH_AR_TABLE_P(h)), \
RHASH_AR_TABLE_SIZE_RAW(h))

Definition at line 436 of file hash.c.

## ◆ RHASH_AR_TABLE_SIZE_INC

#define RHASH_AR_TABLE_SIZE_INC | ( |  | h | ) | HASH_AR_TABLE_SIZE_ADD(h, 1)

Definition at line 623 of file hash.c.

## ◆ RHASH_SET_ST_FLAG

#define RHASH_SET_ST_FLAG | ( |  | h | ) | FL_SET_RAW(h, RHASH_ST_TABLE_FLAG)

Definition at line 590 of file hash.c.

## ◆ RHASH_ST_TABLE_SET

#define RHASH_ST_TABLE_SET | ( |  | h,
|  |  | s
| ) |  | rb_hash_st_table_set(h, s)

Definition at line 446 of file hash.c.

## ◆ RHASH_TYPE

#define RHASH_TYPE | ( |  | hash | ) | (RHASH_AR_TABLE_P(hash) ? &objhash : RHASH_ST_TABLE(hash)->type)

Definition at line 447 of file hash.c.

## ◆ RHASH_UNSET_ST_FLAG

#define RHASH_UNSET_ST_FLAG | ( |  | h | ) | FL_UNSET_RAW(h, RHASH_ST_TABLE_FLAG)

Definition at line 591 of file hash.c.

## ◆ RHASH_UPDATE

#define RHASH_UPDATE | ( |  | hash,
|  |  | key,
|  |  | func,
|  |  | arg
| ) |  | RHASH_UPDATE_ITER(hash, RHASH_ITER_LEV(hash), key, func, arg)

Definition at line 1702 of file hash.c.

## ◆ RHASH_UPDATE_ITER

#define RHASH_UPDATE_ITER | ( |  | h,
|  |  | iter_lev,
|  |  | key,
|  |  | func,
|  |  | a
| ) |  |

Value:
do { \
tbl_update((h), (key), UPDATE_CALLBACK((iter_lev), func), (st_data_t)(a)); \
} while (0)
UPDATE_CALLBACK
#define UPDATE_CALLBACK(iter_lev, func)
Definition: hash.c:1696

Definition at line 1698 of file hash.c.

## ◆ SET_DEFAULT

#define SET_DEFAULT | ( |  | hash,
|  |  | ifnone
| ) |  |

Value:
( \
FL_UNSET_RAW(hash, RHASH_PROC_DEFAULT), \
RHASH_SET_IFNONE(hash, ifnone))

Definition at line 60 of file hash.c.

## ◆ SET_PROC_DEFAULT

#define SET_PROC_DEFAULT | ( |  | hash,
|  |  | proc
| ) |  | set_proc_default(hash, proc)

Definition at line 64 of file hash.c.

## ◆ st_index_hash

#define st_index_hash | ( |  | index | ) | key64_hash(rb_hash_start(index), prime2)

Definition at line 279 of file hash.c.

## ◆ to_hash

#define to_hash rb_to_hash_type

Definition at line 1857 of file hash.c.

## ◆ UPDATE_CALLBACK

#define UPDATE_CALLBACK | ( |  | iter_lev,
|  |  | func
| ) |  | ((iter_lev) > 0 ? func##_noinsert : func##_insert)

Definition at line 1696 of file hash.c.

## Typedef Documentation

## ◆ ar_table

typedef struct ar_table_struct ar_table

## ◆ ar_table_pair

typedef struct ar_table_pair_struct ar_table_pair

## ◆ rb_foreach_func

typedef int rb_foreach_func(VALUE, VALUE, VALUE)

Definition at line 1321 of file hash.c.

## ◆ st_foreach_func

typedef int st_foreach_func(st_data_t, st_data_t, st_data_t)

Definition at line 1286 of file hash.c.

## ◆ st_hash_t

typedef st_index_t st_hash_t

Definition at line 341 of file hash.c.

## ◆ tbl_update_func

typedef int(* tbl_update_func) (st_data_t *, st_data_t *, st_data_t, int)

Definition at line 1656 of file hash.c.

## Function Documentation

## ◆ Init_Hash()

void Init_Hash | ( | void |  | ) |

Definition at line 6839 of file hash.c.

References environ, HASH_ASSERT, id_hash, rb_cHash, rb_cObject, rb_define_alias(), rb_define_alloc_func(), rb_define_class(), rb_define_global_const(), rb_define_method, rb_define_singleton_method, rb_extend_object(), rb_hash_aref(), rb_hash_aset(), rb_hash_assoc(), rb_hash_clear(), rb_hash_compare_by_id_p(), rb_hash_delete_if(), rb_hash_has_key(), rb_hash_keys(), rb_hash_rassoc(), rb_hash_rehash(), rb_hash_reject(), rb_hash_reject_bang(), rb_hash_set_default_proc(), rb_hash_size(), rb_hash_values(), rb_hash_values_at(), rb_include_module(), rb_make_internal_id(), rb_mEnumerable, rb_obj_alloc(), RHASH_AR_TABLE_MAX_SIZE, and ruby_register_rollback_func_for_ensure().

## ◆ rb_check_hash_type()

VALUE rb_check_hash_type | ( | VALUE | hash | ) |

Definition at line 1860 of file hash.c.

References update_arg::hash, rb_check_convert_type_with_id(), and T_HASH.

Referenced by rb_econv_prepare_options(), and rb_Hash().

## ◆ rb_dbl_long_hash()

long rb_dbl_long_hash | ( | double | d | ) |

Definition at line 180 of file hash.c.

References rb_memhash().

## ◆ rb_env_clear()

VALUE rb_env_clear | ( | void |  | ) |

Definition at line 5839 of file hash.c.

References key, RARRAY_AREF, RARRAY_LEN, RB_GC_GUARD, RSTRING_PTR, ruby_setenv(), and TRUE.

Referenced by rb_execarg_run_options().

## ◆ rb_env_path_tainted()

int rb_env_path_tainted | ( | void |  | ) |

Definition at line 5051 of file hash.c.

References rb_warn_deprecated_to_remove().

## ◆ rb_hash()

VALUE rb_hash | ( | VALUE | obj | ) |

Definition at line 143 of file hash.c.

References FIXNUM_MAX, FIXNUM_MIN, FIXNUM_P, id_hash, INTEGER_PACK_NATIVE_BYTE_ORDER, LONG2FIX, Qundef, rb_check_funcall_basic_kw(), rb_exec_recursive_outer(), rb_integer_pack(), rb_mKernel, rb_to_int(), and T_BIGNUM.

Referenced by rb_complex_hash(), and rb_rational_hash().

## ◆ rb_hash_add_new_element()

int rb_hash_add_new_element | ( | VALUE | hash,
|  | VALUE | key,
|  | VALUE | val
| ) |  |

Definition at line 4734 of file hash.c.

References st_hash_type::hash, key, RHASH_TBL_RAW, and st_update.

## ◆ rb_hash_ar_table()

ar_table * rb_hash_ar_table | ( | VALUE | hash | ) |

Definition at line 560 of file hash.c.

References HASH_ASSERT, and RHASH.

## ◆ rb_hash_ar_table_p()

int rb_hash_ar_table_p | ( | VALUE | hash | ) |

Definition at line 548 of file hash.c.

References FALSE, FL_TEST_RAW, HASH_ASSERT, NULL, RHASH, RHASH_ST_TABLE_FLAG, and TRUE.

## ◆ rb_hash_ar_table_size()

size_t rb_hash_ar_table_size | ( | void |  | ) |

Definition at line 369 of file hash.c.

## ◆ rb_hash_aref()

VALUE rb_hash_aref | ( | VALUE | hash,
|  | VALUE | key
| ) |  |

Definition at line 2046 of file hash.c.

References key, and rb_hash_default_value().

Referenced by Init_Hash(), rb_autoload_str(), rb_econv_open_opts(), rb_econv_prepare_options(), rb_hash_values_at(), rb_io_extract_modeenc(), rb_iseq_build_from_ary(), rb_obj_dig(), and rb_warning_category_from_name().

## ◆ rb_hash_aset()

VALUE rb_hash_aset | ( | VALUE | hash,
|  | VALUE | key,
|  | VALUE | val
| ) |  |

Definition at line 2901 of file hash.c.

References identhash, key, rb_cString, rb_obj_class(), RHASH_ITER_LEV, RHASH_TYPE, RHASH_UPDATE_ITER, and shift_var::val.

Referenced by Init_Exception(), Init_GC(), Init_Hash(), Init_ossl_asn1(), Init_ossl_x509name(), InitVM_Enumerator(), olerecord_set_ivar(), rb_ast_add_mark_object(), rb_autoload_str(), rb_econv_prepare_options(), rb_hash_set_pair(), rb_iseq_new_top(), and rb_uninterruptible().

## ◆ rb_hash_assoc()

VALUE rb_hash_assoc | ( | VALUE | hash,
|  | VALUE | key
| ) |  |

Definition at line 4160 of file hash.c.

References st_hash_type::compare, reset_hash_type_arg::hash, st_hash_type::hash, HASH_ASSERT, identhash, key, reset_hash_type_arg::orighash, Qnil, Qundef, rb_assoc_new(), rb_ensure(), rb_hash_foreach(), RHASH_EMPTY_P, and st_table::type.

Referenced by Init_Hash().

## ◆ rb_hash_bulk_insert()

void rb_hash_bulk_insert | ( | long | argc,
|  | const VALUE * | argv,
|  | VALUE | hash
| ) |  |

Definition at line 4777 of file hash.c.

References argc, argv, st_hash_type::hash, HASH_ASSERT, rb_hash_bulk_insert_into_st_table(), RHASH_AR_TABLE_MAX_SIZE, RHASH_AR_TABLE_SIZE, and RHASH_TBL_RAW.

## ◆ rb_hash_clear()

VALUE rb_hash_clear | ( | VALUE | hash | ) |

Definition at line 2819 of file hash.c.

References rb_hash_foreach(), RHASH_ITER_LEV, and st_clear.

Referenced by Init_Hash(), and yyparse().

## ◆ rb_hash_compare_by_id_p()

VALUE rb_hash_compare_by_id_p | ( | VALUE | hash | ) |

Definition at line 4432 of file hash.c.

References st_hash_type::hash, identhash, Qfalse, and Qtrue.

Referenced by Init_Hash().

## ◆ rb_hash_default_value()

VALUE rb_hash_default_value | ( | VALUE | hash,
|  | VALUE | key
| ) |  |

Definition at line 1999 of file hash.c.

References CLASS_OF, FL_TEST, key, LIKELY, Qnil, Qundef, rb_funcall(), rb_method_basic_definition_p, RHASH_IFNONE, and RHASH_PROC_DEFAULT.

Referenced by rb_hash_aref(), and rb_str_format().

## ◆ rb_hash_delete()

VALUE rb_hash_delete | ( | VALUE | hash,
|  | VALUE | key
| ) |  |

Definition at line 2327 of file hash.c.

References key, Qnil, Qundef, and rb_hash_delete_entry().

## ◆ rb_hash_delete_entry()

VALUE rb_hash_delete_entry | ( | VALUE | hash,
|  | VALUE | key
| ) |  |

Definition at line 2309 of file hash.c.

References key, Qundef, and rb_hash_stlike_delete().

Referenced by rb_gc_free_dsymbol(), rb_hash_delete(), and rb_sym2id().

## ◆ rb_hash_delete_if()

VALUE rb_hash_delete_if | ( | VALUE | hash | ) |

Definition at line 2490 of file hash.c.

References rb_hash_foreach(), and RETURN_SIZED_ENUMERATOR.

Referenced by Init_Hash().

## ◆ rb_hash_dup()

VALUE rb_hash_dup | ( | VALUE | hash | ) |

Definition at line 1579 of file hash.c.

References FL_EXIVAR, hash_foreach_arg::hash, rb_copy_generic_ivar(), rb_obj_class(), RBASIC, and RHASH_PROC_DEFAULT.

## ◆ rb_hash_fetch()

VALUE rb_hash_fetch | ( | VALUE | hash,
|  | VALUE | key
| ) |  |

Definition at line 2138 of file hash.c.

References key.

Referenced by rb_category_compile_warn(), rb_category_warn(), and rb_category_warning().

## ◆ rb_hash_foreach()

void rb_hash_foreach | ( | VALUE | hash,
|  | rb_foreach_func * | func,
|  | VALUE | farg
| ) |  |

Definition at line 1498 of file hash.c.

References hash_foreach_arg::arg, hash_foreach_arg::func, hash_foreach_arg::hash, hash_verify, and rb_ensure().

Referenced by ole_rec2variant(), rb_clear_coverages(), rb_extract_keywords(), rb_hash_assoc(), rb_hash_clear(), rb_hash_delete_if(), rb_hash_keys(), rb_hash_rassoc(), rb_hash_rehash(), rb_hash_reject(), rb_hash_reject_bang(), rb_hash_update_by(), rb_hash_values(), and rb_tracepoint_disable().

## ◆ rb_hash_freeze()

VALUE rb_hash_freeze | ( | VALUE | hash | ) |

Definition at line 101 of file hash.c.

References rb_obj_freeze().

Referenced by rb_econv_prepare_options().

## ◆ rb_hash_has_key()

VALUE rb_hash_has_key | ( | VALUE | hash,
|  | VALUE | key
| ) |  |

Definition at line 3638 of file hash.c.

References key, NULL, Qfalse, and Qtrue.

Referenced by Init_Hash().

## ◆ rb_hash_key_str()

VALUE rb_hash_key_str | ( | VALUE | key | ) |

Definition at line 2852 of file hash.c.

References FL_EXIVAR, key, rb_cString, rb_fstring(), rb_str_new_frozen(), and RBASIC_CLASS.

## ◆ rb_hash_keys()

VALUE rb_hash_keys | ( | VALUE | hash | ) |

Definition at line 3549 of file hash.c.

References ptr, RARRAY_PTR_USE_TRANSIENT, rb_ary_new_capa(), rb_ary_set_len(), rb_gc_writebarrier_remember(), rb_hash_foreach(), RHASH_SIZE, ST_DATA_COMPATIBLE_P, and st_keys.

Referenced by Init_Hash().

## ◆ rb_hash_lookup()

VALUE rb_hash_lookup | ( | VALUE | hash,
|  | VALUE | key
| ) |  |

Definition at line 2072 of file hash.c.

References key, Qnil, and rb_hash_lookup2().

## ◆ rb_hash_lookup2()

VALUE rb_hash_lookup2 | ( | VALUE | hash,
|  | VALUE | key,
|  | VALUE | def
| ) |  |

Definition at line 2059 of file hash.c.

References def(), and key.

Referenced by rb_hash_lookup(), rb_io_extract_encoding_option(), and rb_str_format().

## ◆ rb_hash_new()

VALUE rb_hash_new | ( | void |  | ) |

Definition at line 1538 of file hash.c.

References rb_cHash.

Referenced by date__httpdate(), date__iso8601(), date__jisx0301(), date__parse(), date__rfc2822(), date__rfc3339(), date__xmlschema(), Init_GC(), Init_limits(), Init_ossl_asn1(), Init_ossl_x509name(), Init_sizeof(), olerecord_set_ivar(), rb_default_coverage(), rb_econv_prepare_options(), rb_Hash(), rb_hash_new_with_size(), rb_hash_reject(), rb_ident_hash_new(), and yyparse().

## ◆ rb_hash_new_with_size()

VALUE rb_hash_new_with_size | ( | st_index_t | size | ) |

Definition at line 1544 of file hash.c.

References rb_hash_new(), RHASH_AR_TABLE_MAX_SIZE, RHASH_ST_TABLE_SET, and st_init_table_with_size.

Referenced by InitVM_Enumerator().

## ◆ rb_hash_rassoc()

VALUE rb_hash_rassoc | ( | VALUE | hash,
|  | VALUE | obj
| ) |  |

Definition at line 4221 of file hash.c.

References st_hash_type::hash, Qnil, and rb_hash_foreach().

Referenced by Init_Hash().

## ◆ rb_hash_rehash()

VALUE rb_hash_rehash | ( | VALUE | hash | ) |

Definition at line 1960 of file hash.c.

References hash_verify, st_table::num_entries, rb_eRuntimeError, rb_hash_foreach(), rb_raise(), RHASH_ITER_LEV, RHASH_ST_TABLE_SET, st_free_table, st_init_table_with_size, and st_table::type.

Referenced by Init_Hash().

## ◆ rb_hash_reject()

VALUE rb_hash_reject | ( | VALUE | hash | ) |

Definition at line 2560 of file hash.c.

References HAS_EXTRA_STATES, PRIsVALUE, rb_hash_foreach(), rb_hash_new(), rb_warn(), RETURN_SIZED_ENUMERATOR, RHASH_EMPTY_P, RTEST, and ruby_verbose.

Referenced by Init_Hash().

## ◆ rb_hash_reject_bang()

VALUE rb_hash_reject_bang | ( | VALUE | hash | ) |

Definition at line 2519 of file hash.c.

References Qnil, rb_hash_foreach(), RETURN_SIZED_ENUMERATOR, and RHASH_SIZE.

Referenced by Init_Hash().

## ◆ rb_hash_resurrect()

VALUE rb_hash_resurrect | ( | VALUE | hash | ) |

Definition at line 1590 of file hash.c.

References hash_foreach_arg::hash, and rb_cHash.

## ◆ rb_hash_set_default_proc()

VALUE rb_hash_set_default_proc | ( | VALUE | hash,
|  | VALUE | proc
| ) |  |

Definition at line 2234 of file hash.c.

References NIL_P, rb_check_convert_type_with_id(), rb_eTypeError, rb_obj_classname(), rb_obj_is_proc(), rb_raise(), SET_DEFAULT, SET_PROC_DEFAULT, and T_DATA.

Referenced by Init_Hash().

## ◆ rb_hash_set_ifnone()

VALUE rb_hash_set_ifnone | ( | VALUE | hash,
|  | VALUE | ifnone
| ) |  |

Definition at line 113 of file hash.c.

References RB_OBJ_WRITE, and RHASH.

## ◆ rb_hash_set_pair()

VALUE rb_hash_set_pair | ( | VALUE | hash,
|  | VALUE | arg
| ) |  |

Definition at line 3468 of file hash.c.

References NIL_P, RARRAY_AREF, RARRAY_LEN, rb_builtin_class_name(), rb_check_array_type(), rb_eArgError, rb_eTypeError, rb_hash_aset(), and rb_raise().

## ◆ rb_hash_size()

VALUE rb_hash_size | ( | VALUE | hash | ) |

Definition at line 2981 of file hash.c.

References INT2FIX, and RHASH_SIZE.

Referenced by Init_Hash().

## ◆ rb_hash_size_num()

size_t rb_hash_size_num | ( | VALUE | hash | ) |

Definition at line 2987 of file hash.c.

References RHASH_SIZE.

## ◆ rb_hash_st_table()

st_table * rb_hash_st_table | ( | VALUE | hash | ) |

Definition at line 567 of file hash.c.

References HASH_ASSERT, and RHASH.

## ◆ rb_hash_st_table_set()

void rb_hash_st_table_set | ( | VALUE | hash,
|  | st_table * | st
| ) |  |

Definition at line 574 of file hash.c.

References FL_SET_RAW, HASH_ASSERT, NULL, RHASH, and RHASH_ST_TABLE_FLAG.

## ◆ rb_hash_stlike_delete()

int rb_hash_stlike_delete | ( | VALUE | hash,
|  | st_data_t * | pkey,
|  | st_data_t * | pval
| ) |  |

Definition at line 2293 of file hash.c.

References st_delete.

Referenced by rb_hash_delete_entry().

## ◆ rb_hash_stlike_foreach()

int rb_hash_stlike_foreach | ( | VALUE | hash,
|  | st_foreach_callback_func * | func,
|  | st_data_t | arg
| ) |  |

Definition at line 1457 of file hash.c.

References hash_foreach_arg::arg, hash_foreach_arg::func, hash_foreach_arg::hash, and st_foreach.

Referenced by rb_execarg_extract_options().

## ◆ rb_hash_stlike_foreach_with_replace()

int rb_hash_stlike_foreach_with_replace | ( | VALUE | hash,
|  | st_foreach_check_callback_func * | func,
|  | st_update_callback_func * | replace,
|  | st_data_t | arg
| ) |  |

Definition at line 1468 of file hash.c.

References hash_foreach_arg::arg, hash_foreach_arg::func, hash_foreach_arg::hash, and st_foreach_with_replace.

## ◆ rb_hash_stlike_lookup()

int rb_hash_stlike_lookup | ( | VALUE | hash,
|  | st_data_t | key,
|  | st_data_t * | pval
| ) |  |

Definition at line 2026 of file hash.c.

References key.

Referenced by mjit_valid_class_serial_p().

## ◆ rb_hash_stlike_update()

int rb_hash_stlike_update | ( | VALUE | hash,
|  | st_data_t | key,
|  | st_update_callback_func * | func,
|  | st_data_t | arg
| ) |  |

Definition at line 1659 of file hash.c.

References key, and st_update.

## ◆ rb_hash_tbl()

struct st_table * rb_hash_tbl | ( | VALUE | hash,
|  | const char * | file,
|  | int | line
| ) |  |

Definition at line 1609 of file hash.c.

References OBJ_WB_UNPROTECT, and rb_hash_tbl_raw().

## ◆ rb_hash_tbl_raw()

struct st_table * rb_hash_tbl_raw | ( | VALUE | hash,
|  | const char * | file,
|  | int | line
| ) |  |

Definition at line 1603 of file hash.c.

Referenced by rb_hash_tbl().

## ◆ rb_hash_update_by()

VALUE rb_hash_update_by | ( | VALUE | hash1,
|  | VALUE | hash2,
|  | rb_hash_update_func * | func
| ) |  |

Definition at line 4036 of file hash.c.

References update_func_arg::func, update_func_arg::hash, rb_hash_foreach(), and to_hash.

## ◆ rb_hash_values()

VALUE rb_hash_values | ( | VALUE | hash | ) |

Definition at line 3593 of file hash.c.

References ptr, RARRAY_PTR_USE_TRANSIENT, rb_ary_new_capa(), rb_ary_set_len(), rb_gc_writebarrier_remember(), rb_hash_foreach(), RHASH_SIZE, ST_DATA_COMPATIBLE_P, and st_values.

Referenced by Init_Hash().

## ◆ rb_hash_values_at()

VALUE rb_hash_values_at | ( | int | argc,
|  | VALUE * | argv,
|  | VALUE | hash
| ) |  |

Definition at line 2652 of file hash.c.

References argc, argv, rb_ary_new2, rb_ary_push(), and rb_hash_aref().

Referenced by Init_Hash().

## ◆ rb_init_identtable()

st_table * rb_init_identtable | ( | void |  | ) |

Definition at line 4451 of file hash.c.

References identhash, and st_init_table.

Referenced by Init_MemoryView().

## ◆ rb_ivar_set_internal()

void rb_ivar_set_internal | ( | VALUE | obj,
|  | ID | id,
|  | VALUE | val
| ) |  |

Definition at line 1501 of file variable.c.

References rb_is_instance_id(), and VM_ASSERT.

## ◆ rb_to_hash_type()

VALUE rb_to_hash_type | ( | VALUE | hash | ) |

Definition at line 1853 of file hash.c.

References update_arg::hash, rb_convert_type_with_id(), and T_HASH.

## ◆ ruby_setenv()

void ruby_setenv | ( | const char * | name,
|  | const char * | value
| ) |  |

Definition at line 5145 of file hash.c.

References ALLOC_N, ALLOCV_END, ALLOCV_N, environ, fail, free, GET_ENVIRON, L, len, malloc, max, name, NULL, PRIuSIZE, rb_sprintf(), rb_sys_fail_str(), REALLOC_N, ruby_strdup(), snprintf, str, strlen(), and xfree.

Referenced by rb_env_clear(), rb_execarg_run_options(), and ruby_unsetenv().

## ◆ ruby_unsetenv()

void ruby_unsetenv | ( | const char * | name | ) |

Definition at line 5284 of file hash.c.

References name, and ruby_setenv().

## ◆ st_foreach_safe()

void st_foreach_safe | ( | st_table * | table,
|  | st_foreach_func * | func,
|  | st_data_t | a
| ) |  |

Definition at line 1309 of file hash.c.

References foreach_safe_arg::arg, foreach_safe_arg::func, rb_eRuntimeError, rb_raise(), and st_foreach_check.

## Variable Documentation

## ◆ environ

char** environ
| extern

Referenced by Init_Hash(), and ruby_setenv().

## ◆ rb_cHash

VALUE rb_cHash

Definition at line 106 of file hash.c.

Referenced by Init_Hash(), rb_extract_keywords(), rb_hash_new(), and rb_hash_resurrect().

## ◆ rb_hashtype_ident

const struct st_hash_type rb_hashtype_ident

Initial value:
= {
rb_ident_cmp,
rb_ident_hash,
}
rb_ident_cmp
#define rb_ident_cmp
Definition: hash.c:316

Definition at line 336 of file hash.c.