[fontations] Assert layout alignment

This commit is contained in:
Behdad Esfahbod 2025-03-12 00:43:10 -06:00
parent 05cfdb9105
commit 8d300049f5

View file

@ -28,18 +28,22 @@ struct MyAllocator;
unsafe impl GlobalAlloc for MyAllocator {
unsafe fn alloc(&self, layout: Layout) -> *mut u8 {
assert!(layout.align() <= 16);
hb_malloc(layout.size()) as *mut u8
}
unsafe fn alloc_zeroed(&self, layout: Layout) -> *mut u8 {
assert!(layout.align() <= 16);
hb_calloc(layout.size(), 1) as *mut u8
}
unsafe fn realloc(&self, ptr: *mut u8, _layout: Layout, new_size: usize) -> *mut u8 {
unsafe fn realloc(&self, ptr: *mut u8, layout: Layout, new_size: usize) -> *mut u8 {
assert!(layout.align() <= 16);
hb_realloc(ptr as *mut c_void, new_size) as *mut u8
}
unsafe fn dealloc(&self, ptr: *mut u8, _layout: Layout) {
unsafe fn dealloc(&self, ptr: *mut u8, layout: Layout) {
assert!(layout.align() <= 16);
hb_free(ptr as *mut c_void);
}
}