aboutsummaryrefslogtreecommitdiff
path: root/src/stdlib/text.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/stdlib/text.c')
-rw-r--r--src/stdlib/text.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/stdlib/text.c b/src/stdlib/text.c
index 4bf6d999..ccb2510f 100644
--- a/src/stdlib/text.c
+++ b/src/stdlib/text.c
@@ -108,6 +108,7 @@
#include <unistring/version.h>
#include <uniwidth.h>
+#include "../util.h"
#include "bytes.h"
#include "datatypes.h"
#include "integers.h"
@@ -199,9 +200,9 @@ int32_t get_synthetic_grapheme(const ucs4_t *codepoints, int64_t utf32_len) {
if (num_synthetic_graphemes >= synthetic_grapheme_capacity) {
// If we don't have space, allocate more:
synthetic_grapheme_capacity = MAX(128, synthetic_grapheme_capacity * 2);
- synthetic_grapheme_t *new = GC_MALLOC_ATOMIC(sizeof(synthetic_grapheme_t[synthetic_grapheme_capacity]));
- memcpy(new, synthetic_graphemes, sizeof(synthetic_grapheme_t[num_synthetic_graphemes]));
- synthetic_graphemes = new;
+ synthetic_grapheme_t *synth = GC_MALLOC_ATOMIC(sizeof(synthetic_grapheme_t[synthetic_grapheme_capacity]));
+ memcpy(synth, synthetic_graphemes, sizeof(synthetic_grapheme_t[num_synthetic_graphemes]));
+ synthetic_graphemes = synth;
}
int32_t grapheme_id = -(num_synthetic_graphemes + 1);
@@ -1118,7 +1119,7 @@ static bool _has_grapheme(TextIter_t *text, int32_t g) {
}
public
-OptionalInt_t Text$find(Text_t text, Text_t target, Int_t start) {
+PUREFUNC OptionalInt_t Text$find(Text_t text, Text_t target, Int_t start) {
if (text.length < target.length) return NONE_INT;
if (target.length <= 0) return I(1);
TextIter_t text_state = NEW_TEXT_ITER_STATE(text), target_state = NEW_TEXT_ITER_STATE(target);