diff options
| author | WormHeamer | 2026-01-02 19:54:50 -0500 |
|---|---|---|
| committer | WormHeamer | 2026-01-02 19:54:50 -0500 |
| commit | 798afa8d742e39223533865a50f82ad6be10df97 (patch) | |
| tree | b87d27fe71106e458181213b84e18efcdf643b00 | |
| parent | ecdb6e57fcf3b0d4145eac498073bb181f792b6e (diff) | |
add a reminder comment about strings' immutability
| -rw-r--r-- | str.h | 9 |
1 files changed, 8 insertions, 1 deletions
@@ -1,11 +1,16 @@ #ifndef STR_H #define STR_H -#include <string.h> #include <stddef.h> #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 <string.h> + /* conversions */ Str str_from_cstr(const char *s) { |
