Ruby 4.1.0dev (2026-09-25 revision d3f0a612d348635291699f614f22125b396b869b)
stringy.h
1#ifndef PRISM_INTERNAL_STRINGY_H
2#define PRISM_INTERNAL_STRINGY_H
3
4#include "prism/stringy.h"
5
6/*
7 * Backing storage for an empty string.
8 */
9static const uint8_t empty_source[] = "";
10
11/*
12 * Defines an empty string. This is useful for initializing a string that will
13 * be filled in later.
14 */
15#define PM_STRING_EMPTY ((pm_string_t) { .type = PM_STRING_CONSTANT, .source = empty_source, .length = 0 })
16
17/*
18 * Initialize a shared string that is based on initial input.
19 */
20void pm_string_shared_init(pm_string_t *string, const uint8_t *start, const uint8_t *end);
21
22/*
23 * Compare the underlying lengths and bytes of two strings. Returns 0 if the
24 * strings are equal, a negative number if the left string is less than the
25 * right string, and a positive number if the left string is greater than the
26 * right string.
27 */
28int pm_string_compare(const pm_string_t *left, const pm_string_t *right);
29
30/*
31 * Free the associated memory of the given string.
32 */
33void pm_string_cleanup(pm_string_t *string);
34
35#endif
A generic string type that can have various ownership semantics.
A generic string type that can have various ownership semantics.
Definition stringy.h:18