Zig 0.17.0-dev (Split by item)
This is an example of documentation generated by
ZigDoc , an alternative to Zig's built-in
Auto Doc feature. See also
examples in other modes/formats . The project being documented here (as the example) is the Zig library itself.
Zig › compiler_rt/ › memmove.zig › copyBackwards
copyBackwards
memmove.copyBackwards
inline fn copyBackwards (
dest : [*]u8 ,
src : [*]const u8 ,
len : usize ,
) void
File
Code
inline fn copyBackwards (
dest : [*]u8 ,
src : [*]const u8 ,
len : usize ,
) void {
const end_bytes = src [len - @sizeOf (Element ) ..][0 ..@sizeOf (Element )].*;
const start_bytes = src [0 ..@sizeOf (Element )].*;
const d_addr : usize = std .mem .alignBackward (usize , @intFromPtr (dest ) + len , @alignOf (Element ));
const d : [*]Element = @ptrFromInt (d_addr );
const n = d_addr - @intFromPtr (dest );
const s : [*]align (1 ) const Element = @ptrCast (src + n );
const loop_count = n / @sizeOf (Element );
var i : usize = 1 ;
while (i < loop_count + 1 ) : (i += 1 ) {
(d - i )[0 ] = (s - i )[0 ];
}
dest [0 ..@sizeOf (Element )].* = start_bytes ;
dest [len - @sizeOf (Element ) ..][0 ..@sizeOf (Element )].* = end_bytes ;
}