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