mirror of
https://github.com/ruby/ruby.git
synced 2026-10-29 00:46:26 +08:00
We do not want strings to have the ability or the contract of having to be freed. This makes the API simpler and keeps us away from dynamic allocation. https://github.com/ruby/prism/commit/c9b06230ec
31 lines
873 B
C
31 lines
873 B
C
#ifndef PRISM_INTERNAL_STRINGY_H
|
|
#define PRISM_INTERNAL_STRINGY_H
|
|
|
|
#include "prism/stringy.h"
|
|
|
|
/*
|
|
* Backing storage for an empty string.
|
|
*/
|
|
static const uint8_t empty_source[] = "";
|
|
|
|
/*
|
|
* Defines an empty string. This is useful for initializing a string that will
|
|
* be filled in later.
|
|
*/
|
|
#define PM_STRING_EMPTY ((pm_string_t) { .source = empty_source, .length = 0 })
|
|
|
|
/*
|
|
* Initialize a shared string that is based on initial input.
|
|
*/
|
|
void pm_string_shared_init(pm_string_t *string, const uint8_t *start, const uint8_t *end);
|
|
|
|
/*
|
|
* Compare the underlying lengths and bytes of two strings. Returns 0 if the
|
|
* strings are equal, a negative number if the left string is less than the
|
|
* right string, and a positive number if the left string is greater than the
|
|
* right string.
|
|
*/
|
|
int pm_string_compare(const pm_string_t *left, const pm_string_t *right);
|
|
|
|
#endif
|