]> git.lizzy.rs Git - rust.git/blob - src/tools/miri/tests/pass-dep/calloc.rs
Rollup merge of #106441 - mllken:abstract-socket-noref, r=joshtriplett
[rust.git] / src / tools / miri / tests / pass-dep / calloc.rs
1 //@ignore-target-windows: No libc on Windows
2
3 use core::slice;
4
5 fn main() {
6     unsafe {
7         let p1 = libc::calloc(0, 0);
8         assert!(p1.is_null());
9
10         let p2 = libc::calloc(20, 0);
11         assert!(p2.is_null());
12
13         let p3 = libc::calloc(0, 20);
14         assert!(p3.is_null());
15
16         let p4 = libc::calloc(4, 8);
17         assert!(!p4.is_null());
18         let slice = slice::from_raw_parts(p4 as *const u8, 4 * 8);
19         assert_eq!(&slice, &[0_u8; 4 * 8]);
20         libc::free(p4);
21     }
22 }