Ruby 4.1.0dev (2026-04-05 revision a3c372a6dac78cd12d7d9ddc2a35cd3b99d325d7)
Data Structures | Functions
stringy.h File Reference

(a3c372a6dac78cd12d7d9ddc2a35cd3b99d325d7)

A generic string type that can have various ownership semantics. More...

#include "prism/compiler/exported.h"
#include "prism/compiler/nonnull.h"
#include <stddef.h>
#include <stdint.h>
Include dependency graph for stringy.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  pm_string_t
 A generic string type that can have various ownership semantics. More...
 

Functions

PRISM_EXPORTED_FUNCTION void pm_string_constant_init (pm_string_t *string, const char *source, size_t length) PRISM_NONNULL(1)
 Initialize a constant string that doesn't own its memory source.
 
PRISM_EXPORTED_FUNCTION void pm_string_owned_init (pm_string_t *string, uint8_t *source, size_t length) PRISM_NONNULL(1
 Initialize an owned string that is responsible for freeing allocated memory.
 
PRISM_EXPORTED_FUNCTION void PRISM_EXPORTED_FUNCTION size_t pm_string_length (const pm_string_t *string) PRISM_NONNULL(1)
 Returns the length associated with the string.
 
PRISM_EXPORTED_FUNCTION const uint8_t * pm_string_source (const pm_string_t *string) PRISM_NONNULL(1)
 Returns the start pointer associated with the string.
 

Detailed Description

A generic string type that can have various ownership semantics.

Definition in file stringy.h.

Function Documentation

◆ pm_string_constant_init()

PRISM_EXPORTED_FUNCTION void pm_string_constant_init ( pm_string_t string,
const char *  source,
size_t  length 
)

Initialize a constant string that doesn't own its memory source.

Parameters
stringThe string to initialize.
sourceThe source of the string.
lengthThe length of the string.

Definition at line 39 of file stringy.c.

◆ pm_string_length()

PRISM_EXPORTED_FUNCTION void PRISM_EXPORTED_FUNCTION size_t pm_string_length ( const pm_string_t string)

Returns the length associated with the string.

Parameters
stringThe string to get the length of.
Returns
The length of the string.

Definition at line 71 of file stringy.c.

◆ pm_string_owned_init()

PRISM_EXPORTED_FUNCTION void pm_string_owned_init ( pm_string_t string,
uint8_t *  source,
size_t  length 
)

Initialize an owned string that is responsible for freeing allocated memory.

Parameters
stringThe string to initialize.
sourceThe source of the string.
lengthThe length of the string.

◆ pm_string_source()

PRISM_EXPORTED_FUNCTION const uint8_t * pm_string_source ( const pm_string_t string)

Returns the start pointer associated with the string.

Parameters
stringThe string to get the start pointer of.
Returns
The start pointer of the string.

Definition at line 79 of file stringy.c.