summaryrefslogtreecommitdiff
path: root/ucs2.h
diff options
context:
space:
mode:
Diffstat (limited to 'ucs2.h')
-rw-r--r--ucs2.h20
1 files changed, 20 insertions, 0 deletions
diff --git a/ucs2.h b/ucs2.h
index 010d0966..806774c7 100644
--- a/ucs2.h
+++ b/ucs2.h
@@ -36,6 +36,8 @@
#ifndef SHIM_UCS2_H
#define SHIM_UCS2_H
+#include <stdbool.h>
+
static inline INTN
__attribute__((unused))
StrCaseCmp(CHAR16 *s0, CHAR16 *s1)
@@ -89,6 +91,24 @@ StrCSpn(const CHAR16 *s, const CHAR16 *reject)
return ret;
}
+/*
+ * Test if an entire buffer is nothing but NUL characters. This
+ * implementation "gracefully" ignores the difference between the
+ * UTF-8/ASCII 1-byte NUL and the UCS-2 2-byte NUL.
+ */
+static inline bool
+__attribute__((__unused__))
+is_all_nuls(UINT8 *data, UINTN data_size)
+{
+ UINTN i;
+
+ for (i = 0; i < data_size; i++) {
+ if (data[i] != 0)
+ return false;
+ }
+ return true;
+}
+
static inline UINTN
__attribute__((__unused__))
count_ucs2_strings(UINT8 *data, UINTN data_size)