summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2024-06-26 18:48:02 -0400
committerDavid Robillard <d@drobilla.net>2024-06-26 18:52:29 -0400
commitaec0d760835219f91eb483c68ef7b2c8f9e8597e (patch)
treee732377408502d555e53cd67ddf86986da3cee2c /src
parentc147881d999fa966ea266d6feac2a3fabeef511b (diff)
downloadzix-aec0d760835219f91eb483c68ef7b2c8f9e8597e.tar.gz
zix-aec0d760835219f91eb483c68ef7b2c8f9e8597e.tar.bz2
zix-aec0d760835219f91eb483c68ef7b2c8f9e8597e.zip
Add zix_string_view_equals()
Diffstat (limited to 'src')
-rw-r--r--src/string_view.c21
1 files changed, 20 insertions, 1 deletions
diff --git a/src/string_view.c b/src/string_view.c
index 9d98258..192f918 100644
--- a/src/string_view.c
+++ b/src/string_view.c
@@ -1,9 +1,10 @@
-// Copyright 2007-2022 David Robillard <d@drobilla.net>
+// Copyright 2007-2024 David Robillard <d@drobilla.net>
// SPDX-License-Identifier: ISC
#include "zix/string_view.h"
#include "zix/allocator.h"
+#include <stdbool.h>
#include <string.h>
char*
@@ -16,3 +17,21 @@ zix_string_view_copy(ZixAllocator* const allocator, const ZixStringView view)
}
return copy;
}
+
+bool
+zix_string_view_equals(const ZixStringView lhs, const ZixStringView rhs)
+{
+ if (lhs.length != rhs.length) {
+ return false;
+ }
+
+ if (lhs.data != rhs.data) {
+ for (size_t i = 0U; i < lhs.length; ++i) {
+ if (lhs.data[i] != rhs.data[i]) {
+ return false;
+ }
+ }
+ }
+
+ return true;
+}