@@ -112,33 +112,6 @@ impl<'a> Allocation<'a> {
112
112
pub ( crate ) fn set_info ( & mut self , info : AllocationInfo ) {
113
113
self . allocation_info = Some ( info) ;
114
114
}
115
-
116
- fn cleanup_object ( & self , index_offset : usize , view : & AllocationView ) -> Result {
117
- let offset = self . read ( index_offset) ?;
118
- let header = view. read :: < bindings:: binder_object_header > ( offset) ?;
119
- // TODO: Handle other types.
120
- match header. type_ {
121
- BINDER_TYPE_WEAK_BINDER | BINDER_TYPE_BINDER => {
122
- let obj = view. read :: < bindings:: flat_binder_object > ( offset) ?;
123
- let strong = header. type_ == BINDER_TYPE_BINDER ;
124
- // SAFETY: The type is `BINDER_TYPE_{WEAK_}BINDER`, so the `binder` field is
125
- // populated.
126
- let ptr = unsafe { obj. __bindgen_anon_1 . binder } as usize ;
127
- let cookie = obj. cookie as usize ;
128
- self . process . update_node ( ptr, cookie, strong, false ) ;
129
- Ok ( ( ) )
130
- }
131
- BINDER_TYPE_WEAK_HANDLE | BINDER_TYPE_HANDLE => {
132
- let obj = view. read :: < bindings:: flat_binder_object > ( offset) ?;
133
- let strong = header. type_ == BINDER_TYPE_HANDLE ;
134
- // SAFETY: The type is `BINDER_TYPE_{WEAK_}HANDLE`, so the `handle` field is
135
- // populated.
136
- let handle = unsafe { obj. __bindgen_anon_1 . handle } as _ ;
137
- self . process . update_ref ( handle, false , strong)
138
- }
139
- _ => Ok ( ( ) ) ,
140
- }
141
- }
142
115
}
143
116
144
117
impl Drop for Allocation < ' _ > {
@@ -150,7 +123,7 @@ impl Drop for Allocation<'_> {
150
123
if let Some ( info) = & self . allocation_info {
151
124
let view = AllocationView :: new ( self , info. offsets . start ) ;
152
125
for i in info. offsets . clone ( ) . step_by ( size_of :: < usize > ( ) ) {
153
- if self . cleanup_object ( i, & view ) . is_err ( ) {
126
+ if view . cleanup_object ( i) . is_err ( ) {
154
127
pr_warn ! ( "Error cleaning up object at offset {}\n " , i)
155
128
}
156
129
}
@@ -250,4 +223,31 @@ impl<'a> AllocationView<'a> {
250
223
}
251
224
Ok ( ( ) )
252
225
}
226
+
227
+ fn cleanup_object ( & self , index_offset : usize ) -> Result {
228
+ let offset = self . alloc . read ( index_offset) ?;
229
+ let header = self . read :: < bindings:: binder_object_header > ( offset) ?;
230
+ // TODO: Handle other types.
231
+ match header. type_ {
232
+ BINDER_TYPE_WEAK_BINDER | BINDER_TYPE_BINDER => {
233
+ let obj = self . read :: < bindings:: flat_binder_object > ( offset) ?;
234
+ let strong = header. type_ == BINDER_TYPE_BINDER ;
235
+ // SAFETY: The type is `BINDER_TYPE_{WEAK_}BINDER`, so the `binder` field is
236
+ // populated.
237
+ let ptr = unsafe { obj. __bindgen_anon_1 . binder } as usize ;
238
+ let cookie = obj. cookie as usize ;
239
+ self . alloc . process . update_node ( ptr, cookie, strong, false ) ;
240
+ Ok ( ( ) )
241
+ }
242
+ BINDER_TYPE_WEAK_HANDLE | BINDER_TYPE_HANDLE => {
243
+ let obj = self . read :: < bindings:: flat_binder_object > ( offset) ?;
244
+ let strong = header. type_ == BINDER_TYPE_HANDLE ;
245
+ // SAFETY: The type is `BINDER_TYPE_{WEAK_}HANDLE`, so the `handle` field is
246
+ // populated.
247
+ let handle = unsafe { obj. __bindgen_anon_1 . handle } as _ ;
248
+ self . alloc . process . update_ref ( handle, false , strong)
249
+ }
250
+ _ => Ok ( ( ) ) ,
251
+ }
252
+ }
253
253
}
0 commit comments