summaryrefslogtreecommitdiffstats
path: root/include/c/str/len/strlen.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/c/str/len/strlen.h')
-rw-r--r--include/c/str/len/strlen.h35
1 files changed, 35 insertions, 0 deletions
diff --git a/include/c/str/len/strlen.h b/include/c/str/len/strlen.h
new file mode 100644
index 0000000..9ed7a0d
--- /dev/null
+++ b/include/c/str/len/strlen.h
@@ -0,0 +1,35 @@
+// Copyright 2022 Alejandro Colomar <alx@kernel.org>
+// SPDX-License-Identifier: LGPL-3.0-or-later WITH LGPL-3.0-linking-exception
+
+
+#ifndef INCLUDE_C_STR_LEN_STRLEN_H_
+#define INCLUDE_C_STR_LEN_STRLEN_H_
+
+
+#include <stddef.h>
+#include <string.h>
+
+#include <c/str/len/strnul.h>
+
+
+#pragma clang assume_nonnull begin
+inline size_t c_strlen(const char *s);
+inline size_t c_strnlen(const char *s, size_t sz);
+
+
+inline size_t
+c_strlen(const char *s)
+{
+ return c_strnul(s) - s;
+}
+
+
+inline size_t
+c_strnlen(const char *s, size_t sz)
+{
+ return strnlen(s, sz);
+}
+#pragma clang assume_nonnull end
+
+
+#endif // Header guard