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 standard library.
std › mem › Allocator › allocBytesAligned Public Function allocBytesAligned Doc Source Public Function std.mem.Allocator.allocBytesAligned
pub fn allocBytesAligned (
self : Allocator ,
comptime alignment : Alignment ,
byte_count : usize ,
return_address : usize ,
) Error ![*]align (alignment .toByteUnits ()) u8 Params Errors File mem/Allocator.zig: 294
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308 pub fn allocBytesAligned (
self : Allocator ,
comptime alignment : Alignment ,
byte_count : usize ,
return_address : usize ,
) Error ![*]align (alignment .toByteUnits ()) u8 {
if (byte_count == 0 ) {
const ptr = comptime alignment .backward (math .maxInt (usize ));
return @as ([*]align (alignment .toByteUnits ()) u8 , @ptrFromInt (ptr ));
}
const byte_ptr = self .rawAlloc (byte_count , alignment , return_address ) orelse return error .OutOfMemory ;
@memset (byte_ptr [0 ..byte_count ], undefined );
return @alignCast (byte_ptr );
}