diff options
Diffstat (limited to 'boot/common.c')
| -rw-r--r-- | boot/common.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/boot/common.c b/boot/common.c index 6a95bb6..4f9c2ad 100644 --- a/boot/common.c +++ b/boot/common.c @@ -8,6 +8,9 @@ * SPDX-License-Identifier: MPL-2.0 */ +// TODO: merge our common library with `boot/runtime/core.c` +// to avoid implementing a semi-standard library twice! + #pragma once #include <math.h> @@ -239,6 +242,22 @@ string_length(struct String s) return s.length; } +bool +string_equals(const struct String a, const struct String b) +{ + if (string_length(a) != string_length(b)) return false; + if (string_length(a) == 0) return true; + return memcmp(a.data, b.data, a.length) == 0; +} + +bool +string_equals_c_str(const struct String a, const ascii* b) +{ + uint b_length = strlen(b); + if (string_length(a) != b_length) return false; + if (string_length(a) == 0) return true; + return memcmp(a.data, b, a.length) == 0; +} void string_print(struct String s) { |
