noh_string_replace: Use arena from source string

This commit is contained in:
2026-08-11 16:20:53 +02:00
parent f9896a59d9
commit 4291248ec1

View File

@@ -381,6 +381,8 @@ void noh_string_append_cstr(Noh_String *string, const char *cstr);
void noh_string_append_null(Noh_String *string);
// Replace all occurrences of one character with another in a Noh_String.
// If the string does not use an arena, its original data will be cleared.
// If it does not use an arena, this data will remain orphaned in the arena.
void noh_string_replace(Noh_String *string, const char from, const char to);
// Frees a Noh_String, freeing the memory used and settings the count and capacity to 0.
@@ -922,6 +924,7 @@ void noh_string_append_null(Noh_String *string) {
void noh_string_replace(Noh_String *string, const char from, const char to) {
Noh_String result = {0};
result.arena = string->arena;
for (size_t i = 0; i < string->count; i++) {
if (result.arena) {
if (string->elems[i] == from) {