summaryrefslogtreecommitdiff
path: root/string.h
diff options
context:
space:
mode:
authorTom Smeding <tom@tomsmeding.com>2025-02-16 20:03:40 +0100
committerTom Smeding <tom@tomsmeding.com>2025-02-16 20:03:40 +0100
commit39148b1b6dc6c7a10f7e713ece084b6d5cf27537 (patch)
tree619c9d951b1356bfc8dcaba45a66166972992170 /string.h
Initial
Diffstat (limited to 'string.h')
-rw-r--r--string.h19
1 files changed, 19 insertions, 0 deletions
diff --git a/string.h b/string.h
new file mode 100644
index 0000000..ecb49b6
--- /dev/null
+++ b/string.h
@@ -0,0 +1,19 @@
+#pragma once
+
+
+struct string {
+ size_t len, cap;
+ char *data; // null-terminated
+};
+
+struct string string_make(const char *str);
+
+void string_free(struct string s);
+
+// Do not modify the length of the string.
+char* string_read(struct string s);
+
+// Returns original length.
+size_t string_append(struct string *s, char *arg);
+
+void string_truncate(struct string *s, size_t length);