summaryrefslogtreecommitdiffstats
path: root/include/zix/string_view.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/zix/string_view.h')
-rw-r--r--include/zix/string_view.h16
1 files changed, 14 insertions, 2 deletions
diff --git a/include/zix/string_view.h b/include/zix/string_view.h
index f13f8d1..cfd478d 100644
--- a/include/zix/string_view.h
+++ b/include/zix/string_view.h
@@ -1,4 +1,4 @@
-// Copyright 2011-2023 David Robillard <d@drobilla.net>
+// Copyright 2011-2024 David Robillard <d@drobilla.net>
// SPDX-License-Identifier: ISC
#ifndef ZIX_STRING_VIEW_H
@@ -7,6 +7,7 @@
#include "zix/allocator.h"
#include "zix/attributes.h"
+#include <stdbool.h>
#include <stddef.h>
#include <string.h>
@@ -89,11 +90,22 @@ zix_string(const char* const ZIX_NULLABLE str)
/**
Copy a string view into a newly allocated null-terminated string.
*/
-ZIX_API
+ZIX_MALLOC_API
char* ZIX_ALLOCATED
zix_string_view_copy(ZixAllocator* ZIX_NULLABLE allocator, ZixStringView view);
/**
+ Return true if both string views refer to equal strings.
+
+ This may be significantly faster than a full string comparison, because it
+ has fast paths for when the operands have different lengths, or point to the
+ same string data.
+*/
+ZIX_PURE_API
+bool
+zix_string_view_equals(ZixStringView lhs, ZixStringView rhs);
+
+/**
@}
*/