Ruby 4.0.7p0 (2026-09-15 revision 229531a6cfbf07e3caef30dbac24a2a3f3fed482)
rb_data_type_struct::[struct].function Struct Reference

Function pointers. More...

Data Fields

RUBY_DATA_FUNC dmark
 This function is called when the object is experiencing GC marks.
RUBY_DATA_FUNC dfree
 This function is called when the object is no longer used.
size_t(*) dsize (const void *)
 This function is to query the size of the underlying memory regions.
RUBY_DATA_FUNC dcompact
 This function is called when the object is relocated.
void * reserved [1]
 This field is reserved for future extension.

Detailed Description

Function pointers.

Resembles C++ vtbl.

Definition at line 218 of file rtypeddata.h.

Field Documentation

◆ dcompact

RUBY_DATA_FUNC rb_data_type_struct::[struct].function dcompact

This function is called when the object is relocated.

Like ::rb_data_type_struct::dmark, you need to update references to Ruby objects inside of your structs.

See also
rb_gc_location()
Warning
This is called during GC runs. Object allocations are impossible at that moment (that is why GC runs).

◆ dfree

This function is called when the object is no longer used.

You need to do whatever necessary to avoid memory leaks.

Warning
This is called during GC runs. Object allocations are impossible at that moment (that is why GC runs).

◆ dmark

This function is called when the object is experiencing GC marks.

If it contains references to other Ruby objects, you need to mark them also. Otherwise GC will smash your data.

See also
rb_gc_mark()
Warning
This is called during GC runs. Object allocations are impossible at that moment (that is why GC runs).

◆ dsize

size_t(*) rb_data_type_struct::[struct].function(const void *)

This function is to query the size of the underlying memory regions.

◆ reserved

This field is reserved for future extension.

For now, it must be filled with zeros.


The documentation for this struct was generated from the following files: