@@ -67,6 +67,10 @@ mod contents {
67
67
target_os = "dragonfly" , target_os = "windows" , target_env = "musl" ) ,
68
68
link_name = "je_nallocx" ) ]
69
69
fn nallocx ( size : size_t , flags : c_int ) -> size_t ;
70
+ #[ cfg_attr( any( target_os = "macos" , target_os = "android" , target_os = "ios" ,
71
+ target_os = "dragonfly" , target_os = "windows" , target_env = "musl" ) ,
72
+ link_name = "je_sallocx" ) ]
73
+ fn sallocx ( ptr : * mut c_void , flags : c_int ) -> size_t ;
70
74
}
71
75
72
76
const MALLOCX_ZERO : c_int = 0x40 ;
@@ -211,17 +215,28 @@ mod contents {
211
215
#[ no_mangle]
212
216
#[ linkage = "external" ]
213
217
pub unsafe extern fn __rde_realloc_excess ( ptr : * mut u8 ,
214
- old_size : usize ,
218
+ _old_size : usize ,
215
219
old_align : usize ,
216
220
new_size : usize ,
217
221
new_align : usize ,
218
222
excess : * mut usize ,
219
223
err : * mut u8 ) -> * mut u8 {
220
- let p = __rde_realloc ( ptr, old_size, old_align, new_size, new_align, err) ;
221
- if !p. is_null ( ) {
222
- * excess = new_size;
224
+ if new_align != old_align {
225
+ ptr:: write ( err as * mut AllocErr ,
226
+ AllocErr :: Unsupported { details : "can't change alignments" } ) ;
227
+ return 0 as * mut u8
223
228
}
224
- return p
229
+
230
+ let flags = align_to_flags ( new_align) ;
231
+ let ptr = rallocx ( ptr as * mut c_void , new_size, flags) as usize ;
232
+ let alloc_size = sallocx ( ptr as * mut c_void , flags) ;
233
+ if ptr. is_null ( ) {
234
+ let layout = Layout :: from_size_align_unchecked ( new_size, new_align) ;
235
+ ptr:: write ( err as * mut AllocErr ,
236
+ AllocErr :: Exhausted { request : layout } ) ;
237
+ }
238
+ * excess = alloc_size;
239
+ ptr
225
240
}
226
241
227
242
#[ no_mangle]
0 commit comments