We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent ed77937 commit 368c895Copy full SHA for 368c895
src/lib.rs
@@ -32,6 +32,8 @@ const MIN_ALIGN: usize = 8;
32
target_arch = "powerpc64le")))]
33
const MIN_ALIGN: usize = 16;
34
35
+const MALLOCX_ZERO: c_int = 0x40;
36
+
37
// MALLOCX_ALIGN(a) macro
38
fn mallocx_align(a: usize) -> c_int {
39
a.trailing_zeros() as c_int
@@ -51,6 +53,12 @@ pub extern fn __rust_allocate(size: usize, align: usize) -> *mut u8 {
51
53
unsafe { ffi::mallocx(size as size_t, flags) as *mut u8 }
52
54
}
55
56
+#[no_mangle]
57
+pub extern fn __rust_allocate_zeroed(size: usize, align: usize) -> *mut u8 {
58
+ let flags = align_to_flags(align) | MALLOCX_ZERO;
59
+ unsafe { ffi::mallocx(size as size_t, flags) as *mut u8 }
60
+}
61
62
#[no_mangle]
63
pub extern fn __rust_reallocate(ptr: *mut u8,
64
_old_size: usize,
0 commit comments