1#include "prism/internal/stringy.h"
3#include "prism/internal/allocator.h"
13pm_string_shared_init(
pm_string_t *
string,
const uint8_t *start,
const uint8_t *end) {
17 .type = PM_STRING_SHARED,
19 .length = (size_t) (end - start)
27pm_string_owned_init(
pm_string_t *
string, uint8_t *source,
size_t length) {
29 .type = PM_STRING_OWNED,
39pm_string_constant_init(
pm_string_t *
string,
const char *source,
size_t length) {
41 .type = PM_STRING_CONSTANT,
42 .source = (
const uint8_t *) source,
55 size_t left_length = pm_string_length(left);
56 size_t right_length = pm_string_length(right);
58 if (left_length < right_length) {
60 }
else if (left_length > right_length) {
64 return memcmp(pm_string_source(left), pm_string_source(right), left_length);
72 return string->length;
80 return string->source;
88 if (string->
type == PM_STRING_OWNED) {
A generic string type that can have various ownership semantics.
const uint8_t * source
A pointer to the start of the string.
size_t length
The length of the string in bytes of memory.
enum pm_string_t::@110 type
The type of the string.