We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent a59e155 commit fa0755cCopy full SHA for fa0755c
tests/run-pass/calloc.rs
@@ -0,0 +1,26 @@
1
+//ignore-windows: Uses POSIX APIs
2
+
3
+#![feature(rustc_private)]
4
5
+use core::slice;
6
7
+extern crate libc;
8
9
+fn main() {
10
+ unsafe {
11
+ let p1 = libc::calloc(0, 0);
12
+ assert!(p1.is_null());
13
14
+ let p2 = libc::calloc(20, 0);
15
+ assert!(p2.is_null());
16
17
+ let p3 = libc::calloc(0, 20);
18
+ assert!(p3.is_null());
19
20
+ let p4 = libc::calloc(4, 8) as *const u8;
21
+ assert!(!p4.is_null());
22
23
+ let slice = slice::from_raw_parts(p4, 4 * 8);
24
+ assert_eq!(&slice, &[0_u8; 4 * 8]);
25
+ }
26
+}
0 commit comments