Ruby 3.3.7p123 (2025-01-15 revision be31f993d7fa0219d85f7b3c694d454da4ecc10b)
|
Ruby's String. More...
#include <rstring.h>
Data Fields | ||
struct RBasic | basic | |
Basic part, including flags and class. | ||
long | len | |
Length of the string, not including terminating NUL character. | ||
union { | ||
struct { | ||
char * ptr | ||
Pointer to the contents of the string. More... | ||
union { | ||
long capa | ||
Capacity of *ptr . More... | ||
VALUE shared | ||
Parent of the string. More... | ||
} aux | ||
Auxiliary info. More... | ||
} heap | ||
Strings that use separated memory region for contents use this pattern. More... | ||
struct { | ||
char ary [1] | ||
} embed | ||
Embedded contents. More... | ||
} | as | |
String's specific fields. | ||
Ruby's String.
A string in ruby conceptually has these information:
It is worth noting that a string is not an array of characters in ruby. It has never been. In 1.x a string was an array of integers. Since 2.x a string is no longer an array of anything. A string is a string – just like a Time is not an integer.
union { ... } RString::as |
String's specific fields.
Referenced by rb_str_resize().
union { ... } RString::aux |
Auxiliary info.
struct RBasic RString::basic |
long RString::capa |
struct { ... } RString::embed |
Embedded contents.
struct { ... } RString::heap |
Strings that use separated memory region for contents use this pattern.
long RString::len |
char* RString::ptr |
VALUE RString::shared |