objc2_foundation/generated/
NSZone.rs1use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6
7use crate::*;
8
9#[inline]
10pub unsafe extern "C-unwind" fn NSDefaultMallocZone() -> NonNull<NSZone> {
11 extern "C-unwind" {
12 fn NSDefaultMallocZone() -> Option<NonNull<NSZone>>;
13 }
14 let ret = unsafe { NSDefaultMallocZone() };
15 ret.expect("function was marked as returning non-null, but actually returned NULL")
16}
17
18#[inline]
19pub unsafe extern "C-unwind" fn NSCreateZone(
20 start_size: NSUInteger,
21 granularity: NSUInteger,
22 can_free: bool,
23) -> NonNull<NSZone> {
24 extern "C-unwind" {
25 fn NSCreateZone(
26 start_size: NSUInteger,
27 granularity: NSUInteger,
28 can_free: Bool,
29 ) -> Option<NonNull<NSZone>>;
30 }
31 let ret = unsafe { NSCreateZone(start_size, granularity, Bool::new(can_free)) };
32 ret.expect("function was marked as returning non-null, but actually returned NULL")
33}
34
35extern "C-unwind" {
36 pub fn NSRecycleZone(zone: NonNull<NSZone>);
37}
38
39extern "C-unwind" {
40 #[cfg(feature = "NSString")]
41 pub fn NSSetZoneName(zone: *mut NSZone, name: &NSString);
42}
43
44#[cfg(feature = "NSString")]
45#[inline]
46pub unsafe extern "C-unwind" fn NSZoneName(zone: *mut NSZone) -> Retained<NSString> {
47 extern "C-unwind" {
48 fn NSZoneName(zone: *mut NSZone) -> *mut NSString;
49 }
50 let ret = unsafe { NSZoneName(zone) };
51 unsafe { Retained::retain_autoreleased(ret) }
52 .expect("function was marked as returning non-null, but actually returned NULL")
53}
54
55extern "C-unwind" {
56 pub fn NSZoneFromPointer(ptr: NonNull<c_void>) -> *mut NSZone;
57}
58
59#[inline]
60pub unsafe extern "C-unwind" fn NSZoneMalloc(
61 zone: *mut NSZone,
62 size: NSUInteger,
63) -> NonNull<c_void> {
64 extern "C-unwind" {
65 fn NSZoneMalloc(zone: *mut NSZone, size: NSUInteger) -> Option<NonNull<c_void>>;
66 }
67 let ret = unsafe { NSZoneMalloc(zone, size) };
68 ret.expect("function was marked as returning non-null, but actually returned NULL")
69}
70
71#[inline]
72pub unsafe extern "C-unwind" fn NSZoneCalloc(
73 zone: *mut NSZone,
74 num_elems: NSUInteger,
75 byte_size: NSUInteger,
76) -> NonNull<c_void> {
77 extern "C-unwind" {
78 fn NSZoneCalloc(
79 zone: *mut NSZone,
80 num_elems: NSUInteger,
81 byte_size: NSUInteger,
82 ) -> Option<NonNull<c_void>>;
83 }
84 let ret = unsafe { NSZoneCalloc(zone, num_elems, byte_size) };
85 ret.expect("function was marked as returning non-null, but actually returned NULL")
86}
87
88#[inline]
89pub unsafe extern "C-unwind" fn NSZoneRealloc(
90 zone: *mut NSZone,
91 ptr: *mut c_void,
92 size: NSUInteger,
93) -> NonNull<c_void> {
94 extern "C-unwind" {
95 fn NSZoneRealloc(
96 zone: *mut NSZone,
97 ptr: *mut c_void,
98 size: NSUInteger,
99 ) -> Option<NonNull<c_void>>;
100 }
101 let ret = unsafe { NSZoneRealloc(zone, ptr, size) };
102 ret.expect("function was marked as returning non-null, but actually returned NULL")
103}
104
105extern "C-unwind" {
106 pub fn NSZoneFree(zone: *mut NSZone, ptr: NonNull<c_void>);
107}
108
109pub const NSScannedOption: NSUInteger = 1 << 0;
111pub const NSCollectorDisabledOption: NSUInteger = 1 << 1;
113
114#[inline]
115pub unsafe extern "C-unwind" fn NSAllocateCollectable(
116 size: NSUInteger,
117 options: NSUInteger,
118) -> NonNull<c_void> {
119 extern "C-unwind" {
120 fn NSAllocateCollectable(size: NSUInteger, options: NSUInteger) -> Option<NonNull<c_void>>;
121 }
122 let ret = unsafe { NSAllocateCollectable(size, options) };
123 ret.expect("function was marked as returning non-null, but actually returned NULL")
124}
125
126#[inline]
127pub unsafe extern "C-unwind" fn NSReallocateCollectable(
128 ptr: *mut c_void,
129 size: NSUInteger,
130 options: NSUInteger,
131) -> NonNull<c_void> {
132 extern "C-unwind" {
133 fn NSReallocateCollectable(
134 ptr: *mut c_void,
135 size: NSUInteger,
136 options: NSUInteger,
137 ) -> Option<NonNull<c_void>>;
138 }
139 let ret = unsafe { NSReallocateCollectable(ptr, size, options) };
140 ret.expect("function was marked as returning non-null, but actually returned NULL")
141}
142
143extern "C-unwind" {
144 pub fn NSPageSize() -> NSUInteger;
145}
146
147extern "C-unwind" {
148 pub fn NSLogPageSize() -> NSUInteger;
149}
150
151extern "C-unwind" {
152 pub fn NSRoundUpToMultipleOfPageSize(bytes: NSUInteger) -> NSUInteger;
153}
154
155extern "C-unwind" {
156 pub fn NSRoundDownToMultipleOfPageSize(bytes: NSUInteger) -> NSUInteger;
157}
158
159#[inline]
160pub unsafe extern "C-unwind" fn NSAllocateMemoryPages(bytes: NSUInteger) -> NonNull<c_void> {
161 extern "C-unwind" {
162 fn NSAllocateMemoryPages(bytes: NSUInteger) -> Option<NonNull<c_void>>;
163 }
164 let ret = unsafe { NSAllocateMemoryPages(bytes) };
165 ret.expect("function was marked as returning non-null, but actually returned NULL")
166}
167
168extern "C-unwind" {
169 pub fn NSDeallocateMemoryPages(ptr: NonNull<c_void>, bytes: NSUInteger);
170}
171
172extern "C-unwind" {
173 pub fn NSCopyMemoryPages(source: NonNull<c_void>, dest: NonNull<c_void>, bytes: NSUInteger);
174}
175
176extern "C-unwind" {
177 #[deprecated = "Use NSProcessInfo instead"]
178 pub fn NSRealMemoryAvailable() -> NSUInteger;
179}