Ruby 2.7.0p0(2019-12-25revision647ee6f091eafcce70ffb75ddf7e121e192ab217)

Data Structures | Macros | Enumerations | Functions | Variables
array.c File Reference
`#include "ruby/encoding.h"`
`#include "ruby/util.h"`
`#include "ruby/st.h"`
`#include "probes.h"`
`#include "id.h"`
`#include "debug_counter.h"`
`#include "transient_heap.h"`
`#include "internal.h"`
`#include "ruby_assert.h"`

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 | OPTHASH_GIVEN_P(opts) (argc > 0 && !NIL_P((opts) = rb_check_hash_type(argv[argc-1])) && (--argc, 1))
#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))
#define | rb_intern(str) rb_intern_const(str)

## 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_transient_heap_evacuate (VALUE ary, int promote)
void | rb_ary_detransient (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,...)
MJIT_FUNC_EXPORTED 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_ary_tmp_new (long capa)
VALUE | rb_ary_tmp_new_fill (long capa)
void | rb_ary_free (VALUE ary)
RUBY_FUNC_EXPORTED 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)
MJIT_FUNC_EXPORTED 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)
MJIT_FUNC_EXPORTED 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 (VALUE ary, long beg, long len)
VALUE | rb_ary_aref (int argc, const VALUE *argv, VALUE ary)
MJIT_FUNC_EXPORTED 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))

Definition at line 127 of file array.c.

## ◆ ARY_DEFAULT_SIZE

#define ARY_DEFAULT_SIZE 16

Definition at line 32 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)))

Definition at line 64 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)

Definition at line 53 of file array.c.

## ◆ ARY_EMBED_PTR

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

Definition at line 63 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)

Definition at line 60 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 59 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 58 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 68 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)

Definition at line 117 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 112 of file array.c.

## ◆ ARY_MAX_SIZE

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

Definition at line 33 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))

Definition at line 70 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)

Definition at line 129 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 92 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 99 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 103 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 87 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)

Definition at line 137 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 151 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 48 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 136 of file array.c.

## ◆ ARY_SHARED_ROOT_OCCUPIED

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

Definition at line 150 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))

Definition at line 146 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 148 of file array.c.

## ◆ ary_verify

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

Definition at line 222 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 73 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 81 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 155 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 80 of file array.c.

## ◆ FL_UNSET_SHARED

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

Definition at line 85 of file array.c.

## ◆ id_cmp

#define id_cmp idCmp

Definition at line 30 of file array.c.

## ◆ NDEBUG

#define NDEBUG

Definition at line 23 of file array.c.

## ◆ OPTHASH_GIVEN_P

#define OPTHASH_GIVEN_P | ( |  | opts | ) | (argc > 0 && !NIL_P((opts) = rb_check_hash_type(argv[argc-1])) && (--argc, 1))

Definition at line 5314 of file array.c.

## ◆ RAND_UPTO

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

Definition at line 5318 of file array.c.

## ◆ RARRAY_SHARED_ROOT_FLAG

#define RARRAY_SHARED_ROOT_FLAG FL_USER5

Definition at line 145 of file array.c.

## ◆ rb_intern

#define rb_intern | ( |  | str | ) | rb_intern_const(str)

## ◆ RUBY_UNTYPED_DATA_WARNING

#define RUBY_UNTYPED_DATA_WARNING 0

## ◆ SMALL_ARRAY_LEN

#define SMALL_ARRAY_LEN 16

Definition at line 34 of file array.c.

## ◆ tmpary

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

Definition at line 5625 of file array.c.

## ◆ tmpary_discard

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

Definition at line 5626 of file array.c.

## ◆ to_ary

#define to_ary rb_to_array_type

Definition at line 906 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 1145 of file array.c.

## Function Documentation

## ◆ Init_Array()

void Init_Array | ( | void |  | ) |

Definition at line 6919 of file array.c.

References rb_cArray, rb_cObject, rb_define_alloc_func(), rb_define_class(), rb_include_module(), and rb_mEnumerable.

## ◆ rb_ary_aref()

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

Definition at line 1574 of file array.c.

References argc, and rb_check_arity.

## ◆ rb_ary_aref1()

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

Definition at line 1595 of file array.c.

References arg, FIX2LONG, FIXNUM_P, len, NUM2LONG, Qfalse, Qnil, RARRAY_LEN, rb_ary_entry(), rb_ary_subseq(), and rb_range_beg_len().

## ◆ rb_ary_assoc()

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

Definition at line 4156 of file array.c.

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

## ◆ rb_ary_at()

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

Definition at line 1629 of file array.c.

References NUM2LONG, and rb_ary_entry().

## ◆ rb_ary_behead()

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

Definition at line 1369 of file array.c.

References n.

## ◆ rb_ary_cat()

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

Definition at line 1208 of file array.c.

References RARRAY_LEN.

## ◆ rb_ary_clear()

VALUE rb_ary_clear | ( | VALUE | ary | ) |

Definition at line 3862 of file array.c.

Referenced by rb_threadptr_pending_interrupt_clear().

## ◆ rb_ary_cmp()

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

Definition at line 4420 of file array.c.

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

## ◆ rb_ary_concat()

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

Definition at line 4069 of file array.c.

## ◆ rb_ary_delete()

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

Definition at line 3365 of file array.c.

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

## ◆ rb_ary_delete_at()

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

Definition at line 3419 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 3396 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 408 of file array.c.

References assert, and RARRAY_TRANSIENT_P.

## ◆ rb_ary_dup()

VALUE rb_ary_dup | ( | VALUE | ary | ) |

Definition at line 2238 of file array.c.

References dup(), len, RARRAY_LEN, and rb_ary_new2.

Referenced by rb_ary_sort().

## ◆ rb_ary_each()

VALUE rb_ary_each | ( | VALUE | ary | ) |

Definition at line 2129 of file array.c.

References ary_verify, i, and RETURN_SIZED_ENUMERATOR.

## ◆ rb_ary_entry()

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

Definition at line 1512 of file array.c.

Referenced by rb_ary_aref1(), and rb_ary_at().

## ◆ rb_ary_free()

void rb_ary_free | ( | VALUE | ary | ) |

Definition at line 786 of file array.c.

References ARY_HEAP_CAPA, ARY_OWNS_HEAP_P, ARY_SHARED_ROOT_P, RARRAY_LEN, RARRAY_TRANSIENT_P, RB_DEBUG_COUNTER_INC, and USE_DEBUG_COUNTER.

## ◆ rb_ary_freeze()

VALUE rb_ary_freeze | ( | VALUE | ary | ) |

Definition at line 648 of file array.c.

References rb_obj_freeze().

## ◆ rb_ary_includes()

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

Definition at line 4340 of file array.c.

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

## ◆ rb_ary_join()

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

Definition at line 2347 of file array.c.

References i, and len.

## ◆ rb_ary_last()

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

Definition at line 1677 of file array.c.

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

Referenced by rb_gc_register_mark_object().

## ◆ rb_ary_memsize()

RUBY_FUNC_EXPORTED size_t rb_ary_memsize | ( | VALUE | ary | ) |

Definition at line 816 of file array.c.

References ARY_CAPA, and ARY_OWNS_HEAP_P.

## ◆ rb_ary_modify()

void rb_ary_modify | ( | VALUE | ary | ) |

Definition at line 548 of file array.c.

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 723 of file array.c.

References RARRAY_EMBED_LEN_MAX, and rb_ary_new2.

Referenced by ole_methods_from_typeinfo(), ole_variant2val(), ossl_get_errors(), rb_call_end_proc(), rb_f_global_variables(), rb_mod_ancestors(), rb_mod_included_modules(), rb_obj_instance_variables(), and rb_thread_list().

## ◆ rb_ary_new_capa()

VALUE rb_ary_new_capa | ( | long | capa | ) |

Definition at line 717 of file array.c.

Referenced by rb_insns_name_array().

## ◆ rb_ary_new_from_args()

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

Definition at line 729 of file array.c.

References i, n, rb_ary_new2, and va_start.

## ◆ rb_ary_new_from_values()

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

Definition at line 762 of file array.c.

References n, rb_ary_tmp_new_from_values(), and rb_cArray.

## ◆ rb_ary_plus()

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

Definition at line 4000 of file array.c.

References len, RARRAY_LEN, rb_ary_new2, and to_ary.

## ◆ rb_ary_pop()

VALUE rb_ary_pop | ( | VALUE | ary | ) |

Definition at line 1241 of file array.c.

References n.

## ◆ rb_ary_ptr_use_end()

void rb_ary_ptr_use_end | ( | VALUE | ary | ) |

Definition at line 235 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 226 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 1195 of file array.c.

References ary_verify, and RARRAY_LEN.

Referenced by ole_typedesc2val(), ossl_get_errors(), rb_gc_register_mark_object(), rb_get_kwargs(), rb_insns_name_array(), rb_iseq_parameters(), rb_mod_ancestors(), rb_mod_included_modules(), rb_thread_list(), rb_threadptr_pending_interrupt_enque(), and rb_unnamed_parameters().

## ◆ rb_ary_rassoc()

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

Definition at line 4189 of file array.c.

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

## ◆ rb_ary_replace()

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

Definition at line 3811 of file array.c.

## ◆ 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 1955 of file array.c.

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

## ◆ rb_ary_resurrect()

VALUE rb_ary_resurrect | ( | VALUE | ary | ) |

Definition at line 2251 of file array.c.

## ◆ rb_ary_reverse()

VALUE rb_ary_reverse | ( | VALUE | ary | ) |

Definition at line 2544 of file array.c.

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

## ◆ rb_ary_rotate()

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

Definition at line 2617 of file array.c.

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

## ◆ rb_ary_set_len()

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

Definition at line 1932 of file array.c.

## ◆ rb_ary_shared_with_p()

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

Definition at line 661 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 1294 of file array.c.

References len, RARRAY_LEN, and top.

## ◆ rb_ary_sort()

VALUE rb_ary_sort | ( | VALUE | ary | ) |

Definition at line 2866 of file array.c.

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

## ◆ rb_ary_sort_bang()

VALUE rb_ary_sort_bang | ( | VALUE | ary | ) |

Definition at line 2777 of file array.c.

References ary_sort_data::ary, ARY_SHARED_P, assert, RARRAY_LEN, and rb_ary_modify().

Referenced by rb_ary_sort().

## ◆ rb_ary_store()

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

Definition at line 1079 of file array.c.

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

Referenced by 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 1518 of file array.c.

References klass, len, Qnil, RARRAY_LEN, and rb_obj_class().

Referenced by rb_ary_aref1().

## ◆ rb_ary_tmp_new()

VALUE rb_ary_tmp_new | ( | long | capa | ) |

Definition at line 768 of file array.c.

Referenced by Init_vm_objects(), rb_default_coverage(), rb_gc_register_mark_object(), rb_get_kwargs(), and rb_sym_to_proc().

## ◆ rb_ary_tmp_new_fill()

VALUE rb_ary_tmp_new_fill | ( | long | capa | ) |

Definition at line 776 of file array.c.

Referenced by rb_default_coverage().

## ◆ rb_ary_tmp_new_from_values()

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

Definition at line 748 of file array.c.

Referenced by rb_ary_new_from_values().

## ◆ rb_ary_to_ary()

VALUE rb_ary_to_ary | ( | VALUE | obj | ) |

Definition at line 1853 of file array.c.

References NIL_P, obj, rb_ary_new3, and rb_check_array_type().

## ◆ rb_ary_to_s()

VALUE rb_ary_to_s | ( | VALUE | ary | ) |

Definition at line 2453 of file array.c.

## ◆ rb_ary_transient_heap_evacuate()

void rb_ary_transient_heap_evacuate | ( | VALUE | ary,
|  | int | promote
| ) |  |

Definition at line 402 of file array.c.

## ◆ rb_ary_unshift()

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

Definition at line 1494 of file array.c.

## ◆ rb_assoc_new()

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

Definition at line 896 of file array.c.

References rb_ary_new3.

Referenced by rb_big_divrem_normal().

## ◆ rb_check_array_type()

VALUE rb_check_array_type | ( | VALUE | ary | ) |

Definition at line 909 of file array.c.

References idTo_ary, rb_check_convert_type_with_id(), and T_ARRAY.

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

## ◆ rb_check_to_array()

MJIT_FUNC_EXPORTED VALUE rb_check_to_array | ( | VALUE | ary | ) |

Definition at line 915 of file array.c.

References idTo_a, rb_check_convert_type_with_id(), and T_ARRAY.

Referenced by rb_Array().

## ◆ 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 3106 of file array.c.

## ◆ rb_mem_clear()

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

Definition at line 243 of file array.c.

References Qnil, and size.

## ◆ rb_to_array_type()

VALUE rb_to_array_type | ( | VALUE | ary | ) |

Definition at line 902 of file array.c.

References idTo_ary, rb_convert_type_with_id(), and T_ARRAY.

## Variable Documentation

## ◆ rb_cArray

VALUE rb_cArray

Definition at line 27 of file array.c.

Referenced by Init_Array(), and rb_ary_new_from_values().

## ◆ rb_output_fs

VALUE rb_output_fs

Definition at line 584 of file intern.h.

RARRAY_TRANSIENT_P
#define RARRAY_TRANSIENT_P(ary)
Definition: ruby.h:1076
assert
#define assert(x)
Definition: dlmalloc.c:1176
RARRAY_EMBED_LEN_MAX
@ RARRAY_EMBED_LEN_MAX
Definition: ruby.h:1028
VALUE
unsigned long VALUE
Definition: ruby.h:102
ARY_EMBED_P
#define ARY_EMBED_P(ary)
Definition: array.c:53
ARY_HEAP_CAPA
#define ARY_HEAP_CAPA(a)
Definition: array.c:60
ARY_SHARED_ROOT_P
#define ARY_SHARED_ROOT_P(ary)
Definition: array.c:146
ELTS_SHARED
#define ELTS_SHARED
Definition: ruby.h:970
long
#define long
Definition: rb_mjit_min_header-2.7.0.h:2880
RARRAY_SHARED_ROOT_FLAG
#define RARRAY_SHARED_ROOT_FLAG
Definition: array.c:145
RARRAY_EMBED_FLAG
@ RARRAY_EMBED_FLAG
Definition: ruby.h:1029
RARRAY_EMBED_LEN_MASK
@ RARRAY_EMBED_LEN_MASK
Definition: ruby.h:1031
RARRAY_LEN
#define RARRAY_LEN(a)
Definition: ruby.h:1070
FL_TEST_RAW
#define FL_TEST_RAW(x, f)
Definition: ruby.h:1352
n
const char size_t n
Definition: rb_mjit_min_header-2.7.0.h:5456
RARRAY
#define RARRAY(obj)
Definition: ruby.h:1273
RARRAY_EMBED_LEN_SHIFT
@ RARRAY_EMBED_LEN_SHIFT
Definition: ruby.h:1032
RBASIC
#define RBASIC(obj)
Definition: ruby.h:1267
ARY_SHARED_P
#define ARY_SHARED_P(ary)
Definition: array.c:48
OBJ_FROZEN
#define OBJ_FROZEN(x)
Definition: ruby.h:1375