Ruby: array.c File Reference

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

Data Structures | Macros | Enumerations | Functions | Variables
array.c File Reference
`#include "debug_counter.h"`
`#include "id.h"`
`#include "internal.h"`
`#include "internal/array.h"`
`#include "internal/compar.h"`
`#include "internal/enum.h"`
`#include "internal/gc.h"`
`#include "internal/hash.h"`
`#include "internal/numeric.h"`
`#include "internal/object.h"`
`#include "internal/proc.h"`
`#include "internal/rational.h"`
`#include "internal/vm.h"`
`#include "probes.h"`
`#include "ruby/encoding.h"`
`#include "ruby/st.h"`
`#include "ruby/util.h"`
`#include "transient_heap.h"`
`#include "builtin.h"`
`#include "ruby_assert.h"`
`#include "array.rbinc"`

Go to the source code of this file.

## Data Structures
struct | ary_sort_data
struct | select_bang_arg

## Macros
#define | NDEBUG
#define | id_cmp idCmp
#define | ARY_DEFAULT_SIZE 16
#define | ARY_MAX_SIZE (LONG_MAX / (int)sizeof(VALUE))
#define | SMALL_ARRAY_LEN 16
#define | ARY_SHARED_P(ary)
#define | ARY_EMBED_P(ary)
#define | ARY_HEAP_PTR(a) (assert(!ARY_EMBED_P(a)), RARRAY(a)->as.heap.ptr)
#define | ARY_HEAP_LEN(a) (assert(!ARY_EMBED_P(a)), RARRAY(a)->as.heap.len)
#define | ARY_HEAP_CAPA(a)
#define | ARY_EMBED_PTR(a) (assert(ARY_EMBED_P(a)), RARRAY(a)->as.ary)
#define | ARY_EMBED_LEN(a)
#define | ARY_HEAP_SIZE(a) (assert(!ARY_EMBED_P(a)), assert(ARY_OWNS_HEAP_P(a)), ARY_CAPA(a) * sizeof(VALUE))
#define | ARY_OWNS_HEAP_P(a)
#define | FL_SET_EMBED(a)
#define | FL_UNSET_EMBED(ary) FL_UNSET((ary), RARRAY_EMBED_FLAG|RARRAY_EMBED_LEN_MASK)
#define | FL_SET_SHARED(ary)
#define | FL_UNSET_SHARED(ary) FL_UNSET((ary), ELTS_SHARED)
#define | ARY_SET_PTR(ary, p)
#define | ARY_SET_EMBED_LEN(ary, n)
#define | ARY_SET_HEAP_LEN(ary, n)
#define | ARY_SET_LEN(ary, n)
#define | ARY_INCREASE_PTR(ary, n)
#define | ARY_INCREASE_LEN(ary, n)
#define | ARY_CAPA(ary)
#define | ARY_SET_CAPA(ary, n)
#define | ARY_SHARED_ROOT(ary) (assert(ARY_SHARED_P(ary)), RARRAY(ary)->as.heap.aux.shared_root)
#define | ARY_SET_SHARED(ary, value)
#define | RARRAY_SHARED_ROOT_FLAG FL_USER5
#define | ARY_SHARED_ROOT_P(ary)
#define | ARY_SHARED_ROOT_REFCNT(ary) (assert(ARY_SHARED_ROOT_P(ary)), RARRAY(ary)->as.heap.aux.capa)
#define | ARY_SHARED_ROOT_OCCUPIED(ary) (ARY_SHARED_ROOT_REFCNT(ary) == 1)
#define | ARY_SET_SHARED_ROOT_REFCNT(ary, value)
#define | FL_SET_SHARED_ROOT(ary)
#define | ary_verify(ary) ((void)0)
#define | to_ary rb_to_array_type
#define | RAND_UPTO(max) (long)rb_random_ulong_limited((randgen), (max)-1)
#define | RUBY_UNTYPED_DATA_WARNING 0
#define | tmpary(n) rb_ary_tmp_new(n)
#define | tmpary_discard(a) (ary_discard(a), RBASIC_SET_CLASS_RAW(a, rb_cArray))

## Enumerations
enum | ary_take_pos_flags { ARY_TAKE_FIRST = 0 , ARY_TAKE_LAST = 1 }

## Functions
VALUE * | rb_ary_ptr_use_start (VALUE ary)
void | rb_ary_ptr_use_end (VALUE ary)
void | rb_mem_clear (VALUE *mem, long size)
void | rb_ary_detransient (VALUE ary)
void | rb_ary_cancel_sharing (VALUE ary)
void | rb_ary_modify (VALUE ary)
VALUE | rb_ary_freeze (VALUE ary)
VALUE | rb_ary_shared_with_p (VALUE ary1, VALUE ary2)
VALUE | rb_ary_new_capa (long capa)
VALUE | rb_ary_new (void)
VALUE() | rb_ary_new_from_args (long n,...)
VALUE | rb_ary_tmp_new_from_values (VALUE klass, long n, const VALUE *elts)
VALUE | rb_ary_new_from_values (long n, const VALUE *elts)
VALUE | rb_ec_ary_new_from_values (rb_execution_context_t *ec, long n, const VALUE *elts)
VALUE | rb_ary_tmp_new (long capa)
VALUE | rb_ary_tmp_new_fill (long capa)
void | rb_ary_free (VALUE ary)
size_t | rb_ary_memsize (VALUE ary)
VALUE | rb_assoc_new (VALUE car, VALUE cdr)
VALUE | rb_to_array_type (VALUE ary)
VALUE | rb_check_array_type (VALUE ary)
VALUE | rb_check_to_array (VALUE ary)
void | rb_ary_store (VALUE ary, long idx, VALUE val)
VALUE | rb_ary_push (VALUE ary, VALUE item)
VALUE | rb_ary_cat (VALUE ary, const VALUE *argv, long len)
VALUE | rb_ary_pop (VALUE ary)
VALUE | rb_ary_shift (VALUE ary)
VALUE | rb_ary_behead (VALUE ary, long n)
VALUE | rb_ary_unshift (VALUE ary, VALUE item)
VALUE | rb_ary_entry (VALUE ary, long offset)
VALUE | rb_ary_subseq_step (VALUE ary, long beg, long len, long step)
VALUE | rb_ary_subseq (VALUE ary, long beg, long len)
VALUE | rb_ary_aref (int argc, const VALUE *argv, VALUE ary)
VALUE | rb_ary_aref1 (VALUE ary, VALUE arg)
VALUE | rb_ary_at (VALUE ary, VALUE pos)
VALUE | rb_ary_last (int argc, const VALUE *argv, VALUE ary)
VALUE | rb_ary_to_ary (VALUE obj)
void | rb_ary_set_len (VALUE ary, long len)
VALUE | rb_ary_resize (VALUE ary, long len)
| expands or shrinks ary to len elements. More...
VALUE | rb_ary_each (VALUE ary)
VALUE | rb_ary_dup (VALUE ary)
VALUE | rb_ary_resurrect (VALUE ary)
VALUE | rb_ary_join (VALUE ary, VALUE sep)
VALUE | rb_ary_to_s (VALUE ary)
VALUE | rb_ary_reverse (VALUE ary)
VALUE | rb_ary_rotate (VALUE ary, long cnt)
VALUE | rb_ary_sort_bang (VALUE ary)
VALUE | rb_ary_sort (VALUE ary)
VALUE | rb_get_values_at (VALUE obj, long olen, int argc, const VALUE *argv, VALUE(*func)(VALUE, long))
VALUE | rb_ary_delete (VALUE ary, VALUE item)
void | rb_ary_delete_same (VALUE ary, VALUE item)
VALUE | rb_ary_delete_at (VALUE ary, long pos)
VALUE | rb_ary_replace (VALUE copy, VALUE orig)
VALUE | rb_ary_clear (VALUE ary)
VALUE | rb_ary_plus (VALUE x, VALUE y)
VALUE | rb_ary_concat (VALUE x, VALUE y)
VALUE | rb_ary_assoc (VALUE ary, VALUE key)
VALUE | rb_ary_rassoc (VALUE ary, VALUE value)
VALUE | rb_ary_includes (VALUE ary, VALUE item)
VALUE | rb_ary_cmp (VALUE ary1, VALUE ary2)
void | Init_Array (void)

## Variables
VALUE | rb_cArray
VALUE | rb_output_fs

## Macro Definition Documentation

## ◆ ARY_CAPA

#define ARY_CAPA | ( |  | ary | ) |

Value:
(ARY_EMBED_P(ary) ? RARRAY_EMBED_LEN_MAX : \
ARY_SHARED_ROOT_P(ary) ? RARRAY_LEN(ary) : ARY_HEAP_CAPA(ary))
ARY_EMBED_P
#define ARY_EMBED_P(ary)
Definition: array.c:68
ARY_HEAP_CAPA
#define ARY_HEAP_CAPA(a)
Definition: array.c:75
RARRAY_LEN
#define RARRAY_LEN
Definition: rarray.h:52
RARRAY_EMBED_LEN_MAX
#define RARRAY_EMBED_LEN_MAX
Definition: rarray.h:45

Definition at line 142 of file array.c.

## ◆ ARY_DEFAULT_SIZE

#define ARY_DEFAULT_SIZE 16

Definition at line 45 of file array.c.

## ◆ ARY_EMBED_LEN

#define ARY_EMBED_LEN | ( |  | a | ) |

Value:
(assert(ARY_EMBED_P(a)), \
(long)((RBASIC(a)->flags >> RARRAY_EMBED_LEN_SHIFT) & \
(RARRAY_EMBED_LEN_MASK >> RARRAY_EMBED_LEN_SHIFT)))
assert
#define assert(x)
Definition: dlmalloc.c:1176
long
typedef long(ZCALLBACK *tell_file_func) OF((voidpf opaque
RARRAY_EMBED_LEN_SHIFT
#define RARRAY_EMBED_LEN_SHIFT
Definition: rarray.h:46
RARRAY_EMBED_LEN_MASK
#define RARRAY_EMBED_LEN_MASK
Definition: rarray.h:44
RBASIC
#define RBASIC(obj)
Definition: rbasic.h:34

Definition at line 79 of file array.c.

## ◆ ARY_EMBED_P

#define ARY_EMBED_P | ( |  | ary | ) |

Value:
(assert(should_be_T_ARRAY((VALUE)(ary))), \
assert(should_not_be_shared_and_embedded((VALUE)ary)), \
FL_TEST_RAW((ary), RARRAY_EMBED_FLAG) != 0)
RARRAY_EMBED_FLAG
#define RARRAY_EMBED_FLAG
Definition: rarray.h:43
VALUE
unsigned long VALUE
Definition: value.h:38

Definition at line 68 of file array.c.

## ◆ ARY_EMBED_PTR

#define ARY_EMBED_PTR | ( |  | a | ) | (assert(ARY_EMBED_P(a)), RARRAY(a)->as.ary)

Definition at line 78 of file array.c.

## ◆ ARY_HEAP_CAPA

#define ARY_HEAP_CAPA | ( |  | a | ) |

Value:
(assert(!ARY_EMBED_P(a)), assert(!ARY_SHARED_ROOT_P(a)), \
RARRAY(a)->as.heap.aux.capa)
ARY_SHARED_ROOT_P
#define ARY_SHARED_ROOT_P(ary)
Definition: array.c:161

Definition at line 75 of file array.c.

## ◆ ARY_HEAP_LEN

#define ARY_HEAP_LEN | ( |  | a | ) | (assert(!ARY_EMBED_P(a)), RARRAY(a)->as.heap.len)

Definition at line 74 of file array.c.

## ◆ ARY_HEAP_PTR

#define ARY_HEAP_PTR | ( |  | a | ) | (assert(!ARY_EMBED_P(a)), RARRAY(a)->as.heap.ptr)

Definition at line 73 of file array.c.

## ◆ ARY_HEAP_SIZE

#define ARY_HEAP_SIZE | ( |  | a | ) | (assert(!ARY_EMBED_P(a)), assert(ARY_OWNS_HEAP_P(a)), ARY_CAPA(a) * sizeof(VALUE))

Definition at line 83 of file array.c.

## ◆ ARY_INCREASE_LEN

#define ARY_INCREASE_LEN | ( |  | ary,
|  |  | n
| ) |  |

Value:
do { \
assert(!OBJ_FROZEN(ary)); \
if (ARY_EMBED_P(ary)) { \
ARY_SET_EMBED_LEN((ary), RARRAY_LEN(ary)+(n)); \
} \
else { \
RARRAY(ary)->as.heap.len += (n); \
} \
} while (0)
OBJ_FROZEN
#define OBJ_FROZEN
Definition: fl_type.h:136

Definition at line 132 of file array.c.

## ◆ ARY_INCREASE_PTR

#define ARY_INCREASE_PTR | ( |  | ary,
|  |  | n
| ) |  |

Value:
do { \
assert(!ARY_EMBED_P(ary)); \
assert(!OBJ_FROZEN(ary)); \
RARRAY(ary)->as.heap.ptr += (n); \
} while (0)

Definition at line 127 of file array.c.

## ◆ ARY_MAX_SIZE

#define ARY_MAX_SIZE (LONG_MAX / (int)sizeof(VALUE))

Definition at line 46 of file array.c.

## ◆ ARY_OWNS_HEAP_P

#define ARY_OWNS_HEAP_P | ( |  | a | ) |

Value:
(assert(should_be_T_ARRAY((VALUE)(a))), \
!FL_TEST_RAW((a), ELTS_SHARED|RARRAY_EMBED_FLAG))
ELTS_SHARED
#define ELTS_SHARED
Definition: fl_type.h:84
FL_TEST_RAW
#define FL_TEST_RAW
Definition: fl_type.h:131

Definition at line 85 of file array.c.

## ◆ ARY_SET_CAPA

#define ARY_SET_CAPA | ( |  | ary,
|  |  | n
| ) |  |

Value:
do { \
assert(!ARY_EMBED_P(ary)); \
assert(!ARY_SHARED_P(ary)); \
assert(!OBJ_FROZEN(ary)); \
RARRAY(ary)->as.heap.aux.capa = (n); \
} while (0)
ARY_SHARED_P
#define ARY_SHARED_P(ary)
Definition: array.c:63

Definition at line 144 of file array.c.

## ◆ ARY_SET_EMBED_LEN

#define ARY_SET_EMBED_LEN | ( |  | ary,
|  |  | n
| ) |  |

Value:
do { \
long tmp_n = (n); \
assert(ARY_EMBED_P(ary)); \
assert(!OBJ_FROZEN(ary)); \
RBASIC(ary)->flags &= ~RARRAY_EMBED_LEN_MASK; \
RBASIC(ary)->flags |= (tmp_n) << RARRAY_EMBED_LEN_SHIFT; \
} while (0)

Definition at line 107 of file array.c.

## ◆ ARY_SET_HEAP_LEN

#define ARY_SET_HEAP_LEN | ( |  | ary,
|  |  | n
| ) |  |

Value:
do { \
assert(!ARY_EMBED_P(ary)); \
RARRAY(ary)->as.heap.len = (n); \
} while (0)

Definition at line 114 of file array.c.

## ◆ ARY_SET_LEN

#define ARY_SET_LEN | ( |  | ary,
|  |  | n
| ) |  |

Value:
do { \
if (ARY_EMBED_P(ary)) { \
ARY_SET_EMBED_LEN((ary), (n)); \
} \
else { \
ARY_SET_HEAP_LEN((ary), (n)); \
} \
assert(RARRAY_LEN(ary) == (n)); \
} while (0)

Definition at line 118 of file array.c.

## ◆ ARY_SET_PTR

#define ARY_SET_PTR | ( |  | ary,
|  |  | p
| ) |  |

Value:
do { \
assert(!ARY_EMBED_P(ary)); \
assert(!OBJ_FROZEN(ary)); \
RARRAY(ary)->as.heap.ptr = (p); \
} while (0)

Definition at line 102 of file array.c.

## ◆ ARY_SET_SHARED

#define ARY_SET_SHARED | ( |  | ary,
|  |  | value
| ) |  |

Value:
do { \
const VALUE _ary_ = (ary); \
const VALUE _value_ = (value); \
assert(!ARY_EMBED_P(_ary_)); \
assert(ARY_SHARED_P(_ary_)); \
assert(ARY_SHARED_ROOT_P(_value_)); \
RB_OBJ_WRITE(_ary_, &RARRAY(_ary_)->as.heap.aux.shared_root, _value_); \
} while (0)
RARRAY
#define RARRAY(obj)
Definition: rarray.h:42

Definition at line 152 of file array.c.

## ◆ ARY_SET_SHARED_ROOT_REFCNT

#define ARY_SET_SHARED_ROOT_REFCNT | ( |  | ary,
|  |  | value
| ) |  |

Value:
do { \
assert(ARY_SHARED_ROOT_P(ary)); \
RARRAY(ary)->as.heap.aux.capa = (value); \
} while (0)

Definition at line 166 of file array.c.

## ◆ ARY_SHARED_P

#define ARY_SHARED_P | ( |  | ary | ) |

Value:
(assert(should_be_T_ARRAY((VALUE)(ary))), \
assert(should_not_be_shared_and_embedded((VALUE)ary)), \
FL_TEST_RAW((ary),ELTS_SHARED)!=0)

Definition at line 63 of file array.c.

## ◆ ARY_SHARED_ROOT

#define ARY_SHARED_ROOT | ( |  | ary | ) | (assert(ARY_SHARED_P(ary)), RARRAY(ary)->as.heap.aux.shared_root)

Definition at line 151 of file array.c.

## ◆ ARY_SHARED_ROOT_OCCUPIED

#define ARY_SHARED_ROOT_OCCUPIED | ( |  | ary | ) | (ARY_SHARED_ROOT_REFCNT(ary) == 1)

Definition at line 165 of file array.c.

## ◆ ARY_SHARED_ROOT_P

#define ARY_SHARED_ROOT_P | ( |  | ary | ) |

Value:
(assert(should_be_T_ARRAY((VALUE)(ary))), \
FL_TEST_RAW((ary), RARRAY_SHARED_ROOT_FLAG))
RARRAY_SHARED_ROOT_FLAG
#define RARRAY_SHARED_ROOT_FLAG
Definition: array.c:160

Definition at line 161 of file array.c.

## ◆ ARY_SHARED_ROOT_REFCNT

#define ARY_SHARED_ROOT_REFCNT | ( |  | ary | ) | (assert(ARY_SHARED_ROOT_P(ary)), RARRAY(ary)->as.heap.aux.capa)

Definition at line 163 of file array.c.

## ◆ ary_verify

#define ary_verify | ( |  | ary | ) | ((void)0)

Definition at line 239 of file array.c.

## ◆ FL_SET_EMBED

#define FL_SET_EMBED | ( |  | a | ) |

Value:
do { \
assert(!ARY_SHARED_P(a)); \
FL_SET((a), RARRAY_EMBED_FLAG); \
RARY_TRANSIENT_UNSET(a); \
ary_verify(a); \
} while (0)

Definition at line 88 of file array.c.

## ◆ FL_SET_SHARED

#define FL_SET_SHARED | ( |  | ary | ) |

Value:
do { \
assert(!ARY_EMBED_P(ary)); \
FL_SET((ary), ELTS_SHARED); \
} while (0)

Definition at line 96 of file array.c.

## ◆ FL_SET_SHARED_ROOT

#define FL_SET_SHARED_ROOT | ( |  | ary | ) |

Value:
do { \
assert(!ARY_EMBED_P(ary)); \
assert(!RARRAY_TRANSIENT_P(ary)); \
FL_SET((ary), RARRAY_SHARED_ROOT_FLAG); \
} while (0)

Definition at line 170 of file array.c.

## ◆ FL_UNSET_EMBED

#define FL_UNSET_EMBED | ( |  | ary | ) | FL_UNSET((ary), RARRAY_EMBED_FLAG|RARRAY_EMBED_LEN_MASK)

Definition at line 95 of file array.c.

## ◆ FL_UNSET_SHARED

#define FL_UNSET_SHARED | ( |  | ary | ) | FL_UNSET((ary), ELTS_SHARED)

Definition at line 100 of file array.c.

## ◆ id_cmp

#define id_cmp idCmp

Definition at line 43 of file array.c.

## ◆ NDEBUG

#define NDEBUG

Definition at line 36 of file array.c.

## ◆ RAND_UPTO

#define RAND_UPTO | ( |  | max | ) | (long)rb_random_ulong_limited((randgen), (max)-1)

Definition at line 6321 of file array.c.

## ◆ RARRAY_SHARED_ROOT_FLAG

#define RARRAY_SHARED_ROOT_FLAG FL_USER5

Definition at line 160 of file array.c.

## ◆ RUBY_UNTYPED_DATA_WARNING

#define RUBY_UNTYPED_DATA_WARNING 0

## ◆ SMALL_ARRAY_LEN

#define SMALL_ARRAY_LEN 16

Definition at line 47 of file array.c.

## ◆ tmpary

#define tmpary | ( |  | n | ) | rb_ary_tmp_new(n)

Definition at line 6552 of file array.c.

## ◆ tmpary_discard

#define tmpary_discard | ( |  | a | ) | (ary_discard(a), RBASIC_SET_CLASS_RAW(a, rb_cArray))

Definition at line 6553 of file array.c.

## ◆ to_ary

#define to_ary rb_to_array_type

Definition at line 985 of file array.c.

## Enumeration Type Documentation

## ◆ ary_take_pos_flags

enum ary_take_pos_flags

Enumerator
ARY_TAKE_FIRST |
ARY_TAKE_LAST |

Definition at line 1253 of file array.c.

## Function Documentation

## ◆ Init_Array()

void Init_Array | ( | void |  | ) |

Definition at line 8082 of file array.c.

References rb_ary_aref(), rb_ary_assoc(), rb_ary_at(), rb_ary_clear(), rb_ary_cmp(), rb_ary_delete(), rb_ary_each(), rb_ary_includes(), rb_ary_last(), rb_ary_plus(), rb_ary_push(), rb_ary_rassoc(), rb_ary_replace(), rb_ary_sort(), rb_ary_sort_bang(), rb_cArray, rb_cObject, rb_define_alias(), rb_define_alloc_func(), rb_define_class(), rb_define_method, rb_define_singleton_method, rb_include_module(), and rb_mEnumerable.

## ◆ rb_ary_aref()

VALUE rb_ary_aref | ( | int | argc,
|  | const VALUE * | argv,
|  | VALUE | ary
| ) |  |

Definition at line 1802 of file array.c.

References argc, argv, rb_ary_aref1(), and rb_check_arity.

Referenced by Init_Array().

## ◆ rb_ary_aref1()

VALUE rb_ary_aref1 | ( | VALUE | ary,
|  | VALUE | arg
| ) |  |

Definition at line 1823 of file array.c.

References FIX2LONG, FIXNUM_P, len, NUM2LONG, Qfalse, Qnil, RARRAY_LEN, rb_arithmetic_sequence_beg_len_step(), rb_ary_entry(), and rb_ary_subseq_step().

Referenced by rb_ary_aref().

## ◆ rb_ary_assoc()

VALUE rb_ary_assoc | ( | VALUE | ary,
|  | VALUE | key
| ) |  |

Definition at line 4938 of file array.c.

References select_bang_arg::ary, key, NIL_P, Qnil, RARRAY_AREF, RARRAY_LEN, rb_check_array_type(), and rb_equal().

Referenced by Init_Array().

## ◆ rb_ary_at()

VALUE rb_ary_at | ( | VALUE | ary,
|  | VALUE | pos
| ) |  |

Definition at line 1855 of file array.c.

References NUM2LONG, and rb_ary_entry().

Referenced by Init_Array(), and rb_obj_dig().

## ◆ rb_ary_behead()

VALUE rb_ary_behead | ( | VALUE | ary,
|  | long | n
| ) |  |

Definition at line 1521 of file array.c.

References ARY_DEFAULT_SIZE, ARY_SHARED_P, and RARRAY_LEN.

## ◆ rb_ary_cancel_sharing()

void rb_ary_cancel_sharing | ( | VALUE | ary | ) |

Definition at line 565 of file array.c.

References ARY_EMBED_PTR, ARY_HEAP_PTR, ARY_SET_CAPA, ARY_SET_EMBED_LEN, ARY_SET_PTR, ARY_SHARED_P, ARY_SHARED_ROOT, ARY_SHARED_ROOT_OCCUPIED, ary_verify, FL_SET_EMBED, FL_UNSET_SHARED, len, MEMCPY, MEMMOVE, ptr, RARRAY_CONST_PTR_TRANSIENT, RARRAY_EMBED_LEN_MAX, RARRAY_LEN, RARRAY_PTR_USE_TRANSIENT, and rb_gc_writebarrier_remember().

Referenced by rb_ary_modify().

## ◆ rb_ary_cat()

VALUE rb_ary_cat | ( | VALUE | ary,
|  | const VALUE * | argv,
|  | long | len
| ) |  |

Definition at line 1314 of file array.c.

References argv, ARY_SET_LEN, len, and RARRAY_LEN.

Referenced by rb_mod_init_copy().

## ◆ rb_ary_clear()

VALUE rb_ary_clear | ( | VALUE | ary | ) |

Definition at line 4534 of file array.c.

References select_bang_arg::ary, ARY_CAPA, ARY_DEFAULT_SIZE, ARY_EMBED_P, ARY_SET_EMBED_LEN, ARY_SET_LEN, ARY_SHARED_P, ary_verify, and FL_SET_EMBED.

Referenced by Init_Array(), rb_threadptr_pending_interrupt_clear(), and ruby_set_argv().

## ◆ rb_ary_cmp()

VALUE rb_ary_cmp | ( | VALUE | ary1,
|  | VALUE | ary2
| ) |  |

Definition at line 5198 of file array.c.

References INT2FIX, len, NIL_P, Qnil, Qundef, RARRAY_LEN, rb_check_array_type(), and rb_exec_recursive_paired().

Referenced by Init_Array().

## ◆ rb_ary_concat()

VALUE rb_ary_concat | ( | VALUE | x,
|  | VALUE | y
| ) |  |

Definition at line 4859 of file array.c.

References to_ary.

Referenced by yyparse().

## ◆ rb_ary_delete()

VALUE rb_ary_delete | ( | VALUE | ary,
|  | VALUE | item
| ) |  |

Definition at line 3956 of file array.c.

References select_bang_arg::ary, ary_verify, Qnil, RARRAY_AREF, RARRAY_LEN, rb_ary_store(), rb_block_given_p(), rb_equal(), and rb_yield().

Referenced by Init_Array().

## ◆ rb_ary_delete_at()

VALUE rb_ary_delete_at | ( | VALUE | ary,
|  | long | pos
| ) |  |

Definition at line 4010 of file array.c.

References select_bang_arg::ary, ARY_INCREASE_LEN, ary_verify, len, MEMMOVE, ptr, Qnil, RARRAY_AREF, RARRAY_LEN, RARRAY_PTR_USE_TRANSIENT, and rb_ary_modify().

## ◆ rb_ary_delete_same()

void rb_ary_delete_same | ( | VALUE | ary,
|  | VALUE | item
| ) |  |

Definition at line 3987 of file array.c.

References select_bang_arg::ary, RARRAY_AREF, RARRAY_LEN, and rb_ary_store().

## ◆ rb_ary_detransient()

void rb_ary_detransient | ( | VALUE | ary | ) |

Definition at line 432 of file array.c.

## ◆ rb_ary_dup()

VALUE rb_ary_dup | ( | VALUE | ary | ) |

Definition at line 2666 of file array.c.

References ARY_SET_LEN, ary_verify, len, RARRAY_CONST_PTR_TRANSIENT, RARRAY_LEN, and rb_ary_new2.

Referenced by rb_ary_sort().

## ◆ rb_ary_each()

VALUE rb_ary_each | ( | VALUE | ary | ) |

Definition at line 2517 of file array.c.

References ary_verify, RARRAY_AREF, RARRAY_LEN, rb_yield(), and RETURN_SIZED_ENUMERATOR.

Referenced by Init_Array().

## ◆ rb_ary_entry()

VALUE rb_ary_entry | ( | VALUE | ary,
|  | long | offset
| ) |  |

Definition at line 1672 of file array.c.

Referenced by EVENTSINK_Invoke(), rb_ary_aref1(), rb_ary_at(), rb_debug_inspector_frame_binding_get(), rb_debug_inspector_frame_class_get(), rb_debug_inspector_frame_iseq_get(), rb_debug_inspector_frame_self_get(), rb_error_frozen_object(), and rb_resolve_me_location().

## ◆ rb_ary_free()

void rb_ary_free | ( | VALUE | ary | ) |

Definition at line 864 of file array.c.

References ARY_HEAP_CAPA, ARY_OWNS_HEAP_P, ARY_SHARED_P, ARY_SHARED_ROOT_OCCUPIED, ARY_SHARED_ROOT_P, RARRAY_LEN, RB_DEBUG_COUNTER_INC, and USE_DEBUG_COUNTER.

## ◆ rb_ary_freeze()

VALUE rb_ary_freeze | ( | VALUE | ary | ) |

Definition at line 674 of file array.c.

References rb_obj_freeze().

Referenced by rb_method_definition_set().

## ◆ rb_ary_includes()

VALUE rb_ary_includes | ( | VALUE | ary,
|  | VALUE | item
| ) |  |

Definition at line 5126 of file array.c.

References select_bang_arg::ary, Qfalse, Qtrue, RARRAY_AREF, RARRAY_LEN, and rb_equal().

Referenced by Init_Array().

## ◆ rb_ary_join()

VALUE rb_ary_join | ( | VALUE | ary,
|  | VALUE | sep
| ) |  |

Definition at line 2780 of file array.c.

References len, NIL_P, RARRAY_AREF, RARRAY_LEN, rb_check_string_type(), rb_enc_associate(), rb_str_buf_new(), rb_str_new, rb_str_set_len(), rb_usascii_encoding(), rb_usascii_str_new, RSTRING_LEN, and StringValue.

Referenced by rb_insn_operand_intern(), rb_proc_isolate_bang(), and rb_proc_ractor_make_shareable().

## ◆ rb_ary_last()

VALUE rb_ary_last | ( | int | argc,
|  | const VALUE * | argv,
|  | VALUE | ary
| ) |  |

Definition at line 1932 of file array.c.

References argc, argv, ARY_TAKE_LAST, len, Qnil, RARRAY_AREF, and RARRAY_LEN.

Referenced by Init_Array(), and rb_gc_register_mark_object().

## ◆ rb_ary_memsize()

size_t rb_ary_memsize | ( | VALUE | ary | ) |

Definition at line 894 of file array.c.

References ARY_CAPA, and ARY_OWNS_HEAP_P.

## ◆ rb_ary_modify()

void rb_ary_modify | ( | VALUE | ary | ) |

Definition at line 606 of file array.c.

References rb_ary_cancel_sharing().

Referenced by rb_ary_delete_at(), rb_ary_resize(), rb_ary_reverse(), rb_ary_rotate(), rb_ary_sort_bang(), and rb_ary_store().

## ◆ rb_ary_new()

VALUE rb_ary_new | ( | void |  | ) |

Definition at line 749 of file array.c.

References RARRAY_EMBED_LEN_MAX, and rb_ary_new2.

Referenced by EVENTSINK_Invoke(), Init_Encoding(), Init_GC(), Init_load(), Init_ossl_asn1(), Init_VM(), Init_win32ole(), Init_win32ole_event(), ole_methods_from_typeinfo(), ole_variant2val(), ossl_get_errors(), rb_call_end_proc(), rb_f_global_variables(), rb_f_untrace_var(), rb_insn_operand_intern(), rb_memory_view_extract_item_members(), rb_mod_ancestors(), rb_mod_included_modules(), rb_obj_instance_variables(), and rb_ractor_thread_list().

## ◆ rb_ary_new_capa()

VALUE rb_ary_new_capa | ( | long | capa | ) |

Definition at line 743 of file array.c.

References rb_cArray.

Referenced by rb_hash_keys(), rb_hash_values(), and rb_insns_name_array().

## ◆ rb_ary_new_from_args()

VALUE() rb_ary_new_from_args | ( | long | n,
|  |  | ...
| ) |  |

Definition at line 754 of file array.c.

References ARY_SET_LEN, and rb_ary_new2.

## ◆ rb_ary_new_from_values()

VALUE rb_ary_new_from_values | ( | long | n,
|  | const VALUE * | elts
| ) |  |

Definition at line 788 of file array.c.

References rb_ary_tmp_new_from_values(), and rb_cArray.

Referenced by rb_insn_operand_intern().

## ◆ rb_ary_plus()

VALUE rb_ary_plus | ( | VALUE | x,
|  | VALUE | y
| ) |  |

Definition at line 4800 of file array.c.

References ARY_SET_LEN, len, RARRAY_CONST_PTR_TRANSIENT, RARRAY_LEN, rb_ary_new2, and to_ary.

Referenced by Init_Array().

## ◆ rb_ary_pop()

VALUE rb_ary_pop | ( | VALUE | ary | ) |

Definition at line 1350 of file array.c.

References ARY_CAPA, ARY_DEFAULT_SIZE, ARY_OWNS_HEAP_P, ARY_SET_LEN, ary_verify, Qnil, RARRAY_AREF, and RARRAY_LEN.

## ◆ rb_ary_ptr_use_end()

void rb_ary_ptr_use_end | ( | VALUE | ary | ) |

Definition at line 252 of file array.c.

References FL_UNSET_RAW, and RARRAY_PTR_IN_USE_FLAG.

## ◆ rb_ary_ptr_use_start()

VALUE * rb_ary_ptr_use_start | ( | VALUE | ary | ) |

Definition at line 243 of file array.c.

References FL_SET_RAW, RARRAY_CONST_PTR_TRANSIENT, and RARRAY_PTR_IN_USE_FLAG.

## ◆ rb_ary_push()

VALUE rb_ary_push | ( | VALUE | ary,
|  | VALUE | item
| ) |  |

Definition at line 1301 of file array.c.

References ARY_SET_LEN, ary_verify, ptr, RARRAY_LEN, RARRAY_PTR_USE_TRANSIENT, and RB_OBJ_WRITE.

Referenced by EVENTSINK_Invoke(), Init_Array(), Init_Encoding(), Init_VM(), ole_typedesc2val(), ossl_get_errors(), rb_f_global_variables(), rb_f_untrace_var(), rb_gc_register_mark_object(), rb_get_kwargs(), rb_get_values_at(), rb_hash_values_at(), rb_insn_operand_intern(), rb_insns_name_array(), rb_iseq_parameters(), rb_memory_view_extract_item_members(), rb_mod_ancestors(), rb_mod_included_modules(), rb_ractor_thread_list(), rb_threadptr_pending_interrupt_enque(), rb_uninterruptible(), rb_unnamed_parameters(), ruby_init_loadpath(), ruby_set_argv(), and yyparse().

## ◆ rb_ary_rassoc()

VALUE rb_ary_rassoc | ( | VALUE | ary,
|  | VALUE | value
| ) |  |

Definition at line 4967 of file array.c.

References select_bang_arg::ary, Qnil, RARRAY_AREF, RARRAY_LEN, rb_equal(), and T_ARRAY.

Referenced by Init_Array().

## ◆ rb_ary_replace()

VALUE rb_ary_replace | ( | VALUE | copy,
|  | VALUE | orig
| ) |  |

Definition at line 4484 of file array.c.

References ARY_HEAP_LEN, ARY_HEAP_PTR, ARY_OWNS_HEAP_P, ARY_SET_LEN, ARY_SET_PTR, ARY_SHARED_P, ARY_SHARED_ROOT, ary_verify, FL_SET_EMBED, FL_UNSET_EMBED, FL_UNSET_SHARED, RARRAY_CONST_PTR_TRANSIENT, RARRAY_EMBED_LEN_MAX, RARRAY_LEN, and to_ary.

Referenced by Init_Array().

## ◆ rb_ary_resize()

VALUE rb_ary_resize | ( | VALUE | ary,
|  | long | len
| ) |  |

expands or shrinks ary to len elements.

expanded region will be filled with Qnil.

Parameters

  ary | an array
  len | new size

Returns
  ary

Postcondition
  the size of ary is len.

Definition at line 2235 of file array.c.

References ARY_CAPA, ARY_DEFAULT_SIZE, ARY_EMBED_P, ARY_EMBED_PTR, ARY_HEAP_PTR, ARY_MAX_SIZE, ARY_SET_CAPA, ARY_SET_EMBED_LEN, ARY_SET_HEAP_LEN, ARY_SET_LEN, ary_verify, len, MEMCPY, RARRAY_EMBED_LEN_MAX, RARRAY_LEN, rb_ary_modify(), rb_eIndexError, and rb_raise().

Referenced by rb_get_values_at(), rb_mod_init_copy(), and rb_nmin_run().

## ◆ rb_ary_resurrect()

VALUE rb_ary_resurrect | ( | VALUE | ary | ) |

Definition at line 2679 of file array.c.

References RARRAY_LEN, and rb_cArray.

## ◆ rb_ary_reverse()

VALUE rb_ary_reverse | ( | VALUE | ary | ) |

Definition at line 2998 of file array.c.

References len, RARRAY_LEN, RARRAY_PTR_USE_TRANSIENT, and rb_ary_modify().

Referenced by rb_nmin_run().

## ◆ rb_ary_rotate()

VALUE rb_ary_rotate | ( | VALUE | ary,
|  | long | cnt
| ) |  |

Definition at line 3079 of file array.c.

References cnt, len, ptr, Qnil, RARRAY_LEN, RARRAY_PTR_USE_TRANSIENT, and rb_ary_modify().

## ◆ rb_ary_set_len()

void rb_ary_set_len | ( | VALUE | ary,
|  | long | len
| ) |  |

Definition at line 2212 of file array.c.

References ARY_CAPA, ARY_SET_LEN, ARY_SHARED_P, len, rb_bug(), rb_eRuntimeError, and rb_raise().

Referenced by rb_hash_keys(), and rb_hash_values().

## ◆ rb_ary_shared_with_p()

VALUE rb_ary_shared_with_p | ( | VALUE | ary1,
|  | VALUE | ary2
| ) |  |

Definition at line 687 of file array.c.

References ARY_EMBED_P, ARY_SHARED_P, Qfalse, Qtrue, and RARRAY.

Referenced by rb_get_expanded_load_path().

## ◆ rb_ary_shift()

VALUE rb_ary_shift | ( | VALUE | ary | ) |

Definition at line 1413 of file array.c.

References ARY_DEFAULT_SIZE, ARY_EMBED_P, ARY_INCREASE_LEN, ARY_INCREASE_PTR, ARY_SHARED_P, ARY_SHARED_ROOT, ARY_SHARED_ROOT_OCCUPIED, ary_verify, assert, len, MEMMOVE, ptr, Qnil, RARRAY_AREF, RARRAY_LEN, RARRAY_PTR_USE_TRANSIENT, and top.

## ◆ rb_ary_sort()

VALUE rb_ary_sort | ( | VALUE | ary | ) |

Definition at line 3396 of file array.c.

References ary_sort_data::ary, rb_ary_dup(), and rb_ary_sort_bang().

Referenced by Init_Array().

## ◆ rb_ary_sort_bang()

VALUE rb_ary_sort_bang | ( | VALUE | ary | ) |

Definition at line 3298 of file array.c.

References ary_sort_data::ary, ARY_EMBED_LEN, ARY_EMBED_P, ARY_EMBED_PTR, ARY_HEAP_LEN, ARY_HEAP_PTR, ARY_SET_CAPA, ARY_SET_EMBED_LEN, ARY_SET_HEAP_LEN, ARY_SET_LEN, ARY_SET_PTR, ARY_SHARED_P, ary_verify, assert, ary_sort_data::cmp_opt, FL_FREEZE, FL_SET, FL_SET_EMBED, FL_UNSET, FL_UNSET_EMBED, FL_UNSET_SHARED, len, cmp_opt_data::opt_inited, cmp_opt_data::opt_methods, ptr, RARRAY_LEN, RARRAY_PTR_USE, rb_ary_modify(), rb_block_given_p(), rb_cArray, and ruby_qsort().

Referenced by Init_Array(), and rb_ary_sort().

## ◆ rb_ary_store()

void rb_ary_store | ( | VALUE | ary,
|  | long | idx,
|  | VALUE | val
| ) |  |

Definition at line 1141 of file array.c.

References ARY_CAPA, ARY_MAX_SIZE, ARY_SET_LEN, len, RARRAY_LEN, rb_ary_modify(), rb_eIndexError, and rb_raise().

Referenced by Init_ossl_asn1(), ossl_generate_cb_2(), rb_ary_delete(), rb_ary_delete_same(), rb_sym_to_proc(), and rb_unnamed_parameters().

## ◆ rb_ary_subseq()

VALUE rb_ary_subseq | ( | VALUE | ary,
|  | long | beg,
|  | long | len
| ) |  |

Definition at line 1700 of file array.c.

References len, and rb_ary_subseq_step().

## ◆ rb_ary_subseq_step()

VALUE rb_ary_subseq_step | ( | VALUE | ary,
|  | long | beg,
|  | long | len,
|  | long | step
| ) |  |

Definition at line 1678 of file array.c.

References len, Qnil, RARRAY_LEN, rb_cArray, rb_eArgError, and rb_raise().

Referenced by rb_ary_aref1(), and rb_ary_subseq().

## ◆ rb_ary_tmp_new()

VALUE rb_ary_tmp_new | ( | long | capa | ) |

Definition at line 846 of file array.c.

References rb_ary_transient_heap_evacuate, and TRUE.

Referenced by Init_load(), Init_sym(), Init_Thread(), Init_vm_objects(), rb_default_coverage(), rb_gc_register_mark_object(), rb_get_kwargs(), rb_mod_init_copy(), rb_nmin_run(), rb_struct_new(), and rb_sym_to_proc().

## ◆ rb_ary_tmp_new_fill()

VALUE rb_ary_tmp_new_fill | ( | long | capa | ) |

Definition at line 854 of file array.c.

References ARY_SET_LEN, Qnil, rb_ary_transient_heap_evacuate, and TRUE.

Referenced by rb_default_coverage().

## ◆ rb_ary_tmp_new_from_values()

VALUE rb_ary_tmp_new_from_values | ( | VALUE | klass,
|  | long | n,
|  | const VALUE * | elts
| ) |  |

Definition at line 774 of file array.c.

References ARY_SET_LEN.

Referenced by rb_ary_new_from_values().

## ◆ rb_ary_to_ary()

VALUE rb_ary_to_ary | ( | VALUE | obj | ) |

Definition at line 2133 of file array.c.

References NIL_P, rb_ary_new3, and rb_check_array_type().

## ◆ rb_ary_to_s()

VALUE rb_ary_to_s | ( | VALUE | ary | ) |

Definition at line 2894 of file array.c.

## ◆ rb_ary_unshift()

VALUE rb_ary_unshift | ( | VALUE | ary,
|  | VALUE | item
| ) |  |

Definition at line 1654 of file array.c.

## ◆ rb_assoc_new()

VALUE rb_assoc_new | ( | VALUE | car,
|  | VALUE | cdr
| ) |  |

Definition at line 975 of file array.c.

References rb_ary_new3.

Referenced by rb_big_divmod(), rb_big_divrem_normal(), rb_gcdlcm(), rb_hash_assoc(), rsock_s_recvfrom(), rsock_s_recvfrom_nonblock(), and yyparse().

## ◆ rb_check_array_type()

VALUE rb_check_array_type | ( | VALUE | ary | ) |

Definition at line 988 of file array.c.

References rb_check_convert_type_with_id(), and T_ARRAY.

Referenced by rb_Array(), rb_ary_assoc(), rb_ary_cmp(), rb_ary_to_ary(), rb_hash_set_pair(), rb_io_popen(), rb_yield_splat(), and rb_yield_splat_kw().

## ◆ rb_check_to_array()

VALUE rb_check_to_array | ( | VALUE | ary | ) |

Definition at line 994 of file array.c.

References rb_check_convert_type_with_id(), and T_ARRAY.

Referenced by rb_Array().

## ◆ rb_ec_ary_new_from_values()

VALUE rb_ec_ary_new_from_values | ( | rb_execution_context_t * | ec,
|  | long | n,
|  | const VALUE * | elts
| ) |  |

Definition at line 832 of file array.c.

References ARY_SET_LEN, and rb_cArray.

## ◆ rb_get_values_at()

VALUE rb_get_values_at | ( | VALUE | obj,
|  | long | olen,
|  | int | argc,
|  | const VALUE * | argv,
|  | VALUE(*)(VALUE, long) | func
| ) |  |

Definition at line 3673 of file array.c.

References argc, argv, FIX2LONG, FIXNUM_P, len, NUM2LONG, RARRAY_LEN, rb_ary_new2, rb_ary_push(), rb_ary_resize(), and rb_range_beg_len().

## ◆ rb_mem_clear()

void rb_mem_clear | ( | VALUE * | mem,
|  | long | size
| ) |  |

Definition at line 260 of file array.c.

References Qnil.

## ◆ rb_to_array_type()

VALUE rb_to_array_type | ( | VALUE | ary | ) |

Definition at line 981 of file array.c.

References rb_convert_type_with_id(), and T_ARRAY.

## Variable Documentation

## ◆ rb_cArray

VALUE rb_cArray

Definition at line 40 of file array.c.

Referenced by Init_Array(), Init_vm_backtrace(), rb_ary_new_capa(), rb_ary_new_from_values(), rb_ary_resurrect(), rb_ary_sort_bang(), rb_ary_subseq_step(), rb_ec_ary_new_from_values(), and rb_nmin_run().

## ◆ rb_output_fs

VALUE rb_output_fs
| extern

Definition at line 199 of file io.c.