Ruby 4.1.0dev (2026-09-05 revision a946c1bd8e5e7e03e938fe5bb4df942affa95ec6)
Data Structures | Macros | Typedefs
rdata.h File Reference

(a946c1bd8e5e7e03e938fe5bb4df942affa95ec6)

Defines struct RData. More...

#include "ruby/internal/config.h"
#include "ruby/internal/attr/deprecated.h"
#include "ruby/internal/attr/warning.h"
#include "ruby/internal/cast.h"
#include "ruby/internal/core/rbasic.h"
#include "ruby/internal/dllexport.h"
#include "ruby/internal/fl_type.h"
#include "ruby/internal/value.h"
#include "ruby/internal/value_type.h"
#include "ruby/defines.h"
Include dependency graph for rdata.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  RData
 

Macros

#define RUBY_DEFAULT_FREE   RBIMPL_DATA_FUNC(-1)
 This is a value you can set to RData::dfree.
 
#define RUBY_NEVER_FREE   RBIMPL_DATA_FUNC(0)
 This is a value you can set to RData::dfree.
 

Typedefs

typedef void(* RUBY_DATA_FUNC) (void *)
 This is the type of callbacks registered to RData.
 

Detailed Description

Defines struct RData.

Author
Ruby developers ruby-.nosp@m.core.nosp@m.@ruby.nosp@m.-lan.nosp@m.g.org
Warning
Symbols prefixed with either RBIMPL or rbimpl are implementation details. Don't take them as canon. They could rapidly appear then vanish. The name (path) of this header file is also an implementation detail. Do not expect it to persist at the place it is now. Developers are free to move it anywhere anytime at will.
Note
To ruby-core: remember that this header can be possibly recursively included from extension libraries written in C++. Do not expect for instance __VA_ARGS__ is always available. We assume C99 for ruby itself but we don't assume languages of extension libraries. They could be written in C++98.

Definition in file rdata.h.

Macro Definition Documentation

◆ RUBY_DEFAULT_FREE

#define RUBY_DEFAULT_FREE   RBIMPL_DATA_FUNC(-1)

This is a value you can set to RData::dfree.

Setting this means the data was allocated using ruby_xmalloc() (or variants), and shall be freed using ruby_xfree().

Warning
Do not use this if you want to use system malloc, because the system and Ruby might or might not share the same malloc implementation.

Definition at line 56 of file rdata.h.

◆ RUBY_NEVER_FREE

#define RUBY_NEVER_FREE   RBIMPL_DATA_FUNC(0)

This is a value you can set to RData::dfree.

Setting this means the data is managed by someone else, like, statically allocated. Of course you are on your own then.

Definition at line 63 of file rdata.h.

Typedef Documentation

◆ RUBY_DATA_FUNC

typedef void(* RUBY_DATA_FUNC) (void *)

This is the type of callbacks registered to RData.

The argument is the data field.

Definition at line 69 of file rdata.h.