summaryrefslogtreecommitdiff
path: root/src/string_view.c
diff options
context:
space:
mode:
authorJohnny Richard <johnny@johnnyrichard.com>2025-04-11 01:15:01 +0200
committerJohnny Richard <johnny@johnnyrichard.com>2025-04-14 23:11:22 +0200
commite7f69c8fbbbcbddde84933b2becd91e787d1ac63 (patch)
tree16cd17da17133494dd06aab614724e76b059d4ad /src/string_view.c
Intial commit
Signed-off-by: Johnny Richard <johnny@johnnyrichard.com>
Diffstat (limited to 'src/string_view.c')
-rw-r--r--src/string_view.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/string_view.c b/src/string_view.c
new file mode 100644
index 0000000..fbdad23
--- /dev/null
+++ b/src/string_view.c
@@ -0,0 +1,14 @@
+#include <string.h>
+#include "string_view.h"
+
+string_view_t
+string_view_from_cstr(char *cstr)
+{
+ return (string_view_t) { .size = strlen(cstr), .chars = cstr };
+}
+
+bool
+string_view_eq(string_view_t s1, string_view_t s2)
+{
+ return s1.size == s2.size && memcmp(s1.chars, s2.chars, s1.size) == 0;
+}