From 798afa8d742e39223533865a50f82ad6be10df97 Mon Sep 17 00:00:00 2001 From: WormHeamer Date: Fri, 2 Jan 2026 19:54:50 -0500 Subject: add a reminder comment about strings' immutability --- str.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/str.h b/str.h index 1969d6b..33decac 100644 --- a/str.h +++ b/str.h @@ -1,11 +1,16 @@ #ifndef STR_H #define STR_H -#include #include #include "arena.h" +/* non-const *s for convenience's sake, but strings should + * be treated as immutable unless absolutely certain there + * are no dangling references to substrings concatenated + * into it (because str_cat() is sometimes in-place). + */ + typedef struct { char *s; ptrdiff_t n; @@ -43,6 +48,8 @@ Str str_replace_end(Str s, Str a, Str b, Arena *m); #ifdef STR_IMPL +#include + /* conversions */ Str str_from_cstr(const char *s) { -- cgit v1.2.3