mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-09 07:08:59 +00:00
slightly better memset/memcpy implementation
This commit is contained in:
parent
f87be94f6a
commit
3b921afc69
1 changed files with 2 additions and 11 deletions
|
|
@ -9,26 +9,17 @@ const builtin = @import("builtin");
|
|||
export fn memset(dest: ?&u8, c: u8, n: usize) {
|
||||
@setDebugSafety(this, false);
|
||||
|
||||
if (n == 0)
|
||||
return;
|
||||
|
||||
const d = ??dest;
|
||||
var index: usize = 0;
|
||||
while (index != n; index += 1)
|
||||
d[index] = c;
|
||||
(??dest)[index] = c;
|
||||
}
|
||||
|
||||
export fn memcpy(noalias dest: ?&u8, noalias src: ?&const u8, n: usize) {
|
||||
@setDebugSafety(this, false);
|
||||
|
||||
if (n == 0)
|
||||
return;
|
||||
|
||||
const d = ??dest;
|
||||
const s = ??src;
|
||||
var index: usize = 0;
|
||||
while (index != n; index += 1)
|
||||
d[index] = s[index];
|
||||
(??dest)[index] = (??src)[index];
|
||||
}
|
||||
|
||||
export fn __stack_chk_fail() {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue