1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
include!;
use ;
/// This function allocates a new device and returns a pointer to it if no error occured. For the
/// required structure of `T` check the example below. If an error occurs the pointer `errptr` points
/// to will be set to to a pointer pointing to the error and null returned from this function.
///
/// # Safety
///
/// The caller must ensure `ctx` and `errptr` to be a valid pointers.
///
/// It must also ensure `T` to be a type that starts with `fz_device`. Memory will be allocated for
/// a new instance of `T`, but only the `fz_device` portion will be initialized. The rest is
/// currently being zero-initialized, but this might change in the future.
///
/// The `*mut T` pointer returned is only guaranteed to be well aligned up to the alignment
/// of [`max_align_t`].
///
/// # Example
///
/// This is how a compliant `T` might look like. The `repr(C)` is necessary as `repr(Rust)` does
/// not guarantee stable field orderings.
///
/// ```rust
/// use mupdf_sys::{fz_device, max_align_t};
///
/// #[repr(C)]
/// struct MyDevice {
/// base: fz_device,
/// foo: u32,
/// }
///
/// const { assert!(align_of::<MyDevice>() <= align_of::<max_align_t>()); }
/// ```
pub unsafe