summaryrefslogtreecommitdiff
path: root/strings/strings.h
diff options
context:
space:
mode:
authortalha <talha@talhaamir.xyz>2024-02-15 09:58:42 +0500
committertalha <talha@talhaamir.xyz>2024-02-15 09:58:42 +0500
commitab3edaa58eed4ff73410954ca094531d49eb5844 (patch)
tree4dd8dc896baa5737153ed0d48f27881171fd3287 /strings/strings.h
added personal libraries to git tracking
Diffstat (limited to 'strings/strings.h')
-rw-r--r--strings/strings.h42
1 files changed, 42 insertions, 0 deletions
diff --git a/strings/strings.h b/strings/strings.h
new file mode 100644
index 0000000..dbaff7a
--- /dev/null
+++ b/strings/strings.h
@@ -0,0 +1,42 @@
+#ifndef AMR_STR
+#define AMR_STR
+
+#include <assert.h>
+#include <string.h>
+
+#define MemCopy memcpy
+
+// @todo: the function names have been changed a bit for the interest
+// of speed. Some structs and functions share the same names, so
+// I need to fix this but also make sure the functions have good names
+
+enum StrStatus {STR_OK=0, STR_FULL};
+
+struct str8 {
+ u8 *buffer;
+ u64 size;
+};
+
+struct str8_node {
+ str8_node *next;
+ str8 string;
+};
+
+struct str8_list {
+ str8_node *first;
+ str8_node *last;
+ u64 count;
+ u64 capacity;
+};
+
+struct res_str8 {
+ str8 string;
+ u64 bytes_count;
+ enum StrStatus status;
+};
+
+struct str8 Str8(u8 *string, u64 size);
+u64 CstrSize(const char* cstr);
+struct res_str8 Str8InitCstr(struct arena *a, const char* cstr, u64 size);
+
+#endif