aboutsummaryrefslogtreecommitdiff
path: root/system.old/libraries/mem/mem.zig
diff options
context:
space:
mode:
Diffstat (limited to 'system.old/libraries/mem/mem.zig')
-rw-r--r--system.old/libraries/mem/mem.zig22
1 files changed, 22 insertions, 0 deletions
diff --git a/system.old/libraries/mem/mem.zig b/system.old/libraries/mem/mem.zig
new file mode 100644
index 0000000..b513567
--- /dev/null
+++ b/system.old/libraries/mem/mem.zig
@@ -0,0 +1,22 @@
+//! Memory utilities
+
+pub fn copy(dest: []u8, src: []const u8) void {
+ const len = @min(dest.len, src.len);
+ for (0..len) |i| {
+ dest[i] = src[i];
+ }
+}
+
+pub fn zero(buf: []u8) void {
+ for (buf) |*b| {
+ b.* = 0;
+ }
+}
+
+pub fn equals(a: []const u8, b: []const u8) bool {
+ if (a.len != b.len) return false;
+ for (a, b) |ac, bc| {
+ if (ac != bc) return false;
+ }
+ return true;
+}