Skip to content

Commit 8d2d754

Browse files
authored
Update null defaults in woff2 (#4)
1 parent 671900b commit 8d2d754

3 files changed

Lines changed: 50 additions & 50 deletions

File tree

woff2/out/unsafe/src/bin/woff2_compress.rs

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ impl woff2_Buffer {
227227
}
228228
pub unsafe fn Skip(&mut self, mut n_bytes: u64) -> bool {
229229
return (unsafe {
230-
let _data: *mut u8 = Default::default();
230+
let _data: *mut u8 = std::ptr::null_mut();
231231
let _n_bytes: u64 = n_bytes;
232232
self.Read(_data, _n_bytes)
233233
});
@@ -696,7 +696,7 @@ impl woff2_Font {
696696
return if it
697697
== UnsafeMapIterator::end(&self.tables as *const BTreeMap<u32, Box<woff2_Font_Table>>)
698698
{
699-
Default::default()
699+
std::ptr::null_mut()
700700
} else {
701701
(&mut *it.second() as *mut woff2_Font_Table)
702702
};
@@ -711,7 +711,7 @@ impl woff2_Font {
711711
return if it
712712
== UnsafeMapIterator::end(&self.tables as *const BTreeMap<u32, Box<woff2_Font_Table>>)
713713
{
714-
Default::default()
714+
std::ptr::null()
715715
} else {
716716
(&*it.second() as *const woff2_Font_Table)
717717
};
@@ -796,7 +796,7 @@ pub unsafe fn ReadTrueTypeFont_15(
796796
'loop_: while ((i as i32) < ((*font).num_tables as i32)) {
797797
let mut table: woff2_Font_Table = <woff2_Font_Table>::default();
798798
table.flag_byte = 0_u8;
799-
table.reuse_of = Default::default();
799+
table.reuse_of = std::ptr::null_mut();
800800
if (((!(unsafe {
801801
let _value: *mut u32 = (&mut table.tag as *mut u32);
802802
(*file).ReadU32(_value)
@@ -846,7 +846,7 @@ pub unsafe fn ReadTrueTypeFont_15(
846846
(*font).FindTable_u32(_tag)
847847
})
848848
.cast_const();
849-
if ((head_table) != (Default::default())) && (((*head_table).length) < (52_u32)) {
849+
if ((head_table) != (std::ptr::null())) && (((*head_table).length) < (52_u32)) {
850850
return false;
851851
}
852852
return true;
@@ -1324,7 +1324,7 @@ pub unsafe fn NumGlyphs_27(font: *const woff2_Font) -> i32 {
13241324
let _tag: u32 = woff2_kLocaTableTag;
13251325
(*font).FindTable_u32_const(_tag)
13261326
});
1327-
if (((head_table) == (Default::default())) || ((loca_table) == (Default::default())))
1327+
if (((head_table) == (std::ptr::null())) || ((loca_table) == (std::ptr::null())))
13281328
|| (((*head_table).length) < (52_u32))
13291329
{
13301330
return 0;
@@ -1345,14 +1345,14 @@ pub unsafe fn IndexFormat_28(font: *const woff2_Font) -> i32 {
13451345
let _tag: u32 = woff2_kHeadTableTag;
13461346
(*font).FindTable_u32_const(_tag)
13471347
});
1348-
if ((head_table) == (Default::default())) {
1348+
if ((head_table) == (std::ptr::null())) {
13491349
return 0;
13501350
}
13511351
return ((*(*head_table).data.offset((51) as isize)) as i32);
13521352
}
13531353
impl woff2_Font_Table {
13541354
pub unsafe fn IsReused(&self) -> bool {
1355-
return ((self.reuse_of) != (Default::default()));
1355+
return ((self.reuse_of) != (std::ptr::null_mut()));
13561356
}
13571357
}
13581358
pub unsafe fn GetGlyphData_29(
@@ -1376,8 +1376,8 @@ pub unsafe fn GetGlyphData_29(
13761376
let _tag: u32 = woff2_kGlyfTableTag;
13771377
(*font).FindTable_u32_const(_tag)
13781378
});
1379-
if ((((head_table) == (Default::default())) || ((loca_table) == (Default::default())))
1380-
|| ((glyf_table) == (Default::default())))
1379+
if ((((head_table) == (std::ptr::null())) || ((loca_table) == (std::ptr::null())))
1380+
|| ((glyf_table) == (std::ptr::null())))
13811381
|| (((*head_table).length) < (52_u32))
13821382
{
13831383
return false;
@@ -1475,10 +1475,10 @@ impl woff2_Glyph {
14751475
y_min: 0_i16,
14761476
y_max: 0_i16,
14771477
instructions_size: 0_u16,
1478-
instructions_data: Default::default(),
1478+
instructions_data: std::ptr::null(),
14791479
overlap_simple_flag_set: false,
14801480
contours: Vec::new(),
1481-
composite_data: Default::default(),
1481+
composite_data: std::ptr::null(),
14821482
composite_data_size: 0_u32,
14831483
have_instructions: false,
14841484
};
@@ -2122,7 +2122,7 @@ pub unsafe fn WriteNormalizedLoca_42(
21222122
let mut glyf_dst: *mut u8 = if (num_glyphs != 0) {
21232123
(&mut (&mut (*glyf_table)).buffer[(0_u64) as usize] as *mut u8)
21242124
} else {
2125-
Default::default()
2125+
std::ptr::null_mut()
21262126
};
21272127
let mut loca_dst: *mut u8 = (&mut (&mut (*loca_table)).buffer[(0_u64) as usize] as *mut u8);
21282128
let mut glyf_offset: u32 = 0_u32;
@@ -2137,7 +2137,7 @@ pub unsafe fn WriteNormalizedLoca_42(
21372137
StoreLoca_41(_index_fmt, _value, _offset, _dst)
21382138
});
21392139
let mut glyph: woff2_Glyph = woff2_Glyph::woff2_Glyph();
2140-
let mut glyph_data: *const u8 = Default::default();
2140+
let mut glyph_data: *const u8 = std::ptr::null();
21412141
let mut glyph_size: u64 = 0_u64;
21422142
if (!(unsafe {
21432143
let _font: *const woff2_Font = &(*font) as *const woff2_Font;
@@ -2193,14 +2193,14 @@ pub unsafe fn WriteNormalizedLoca_42(
21932193
(*glyf_table).data = if (glyf_offset != 0) {
21942194
(&mut (&mut (*glyf_table)).buffer[(0_u64) as usize] as *mut u8)
21952195
} else {
2196-
Default::default()
2196+
std::ptr::null_mut()
21972197
}
21982198
.cast_const();
21992199
(*glyf_table).length = glyf_offset;
22002200
(*loca_table).data = if (loca_offset != 0) {
22012201
(&mut (&mut (*loca_table)).buffer[(0_u64) as usize] as *mut u8)
22022202
} else {
2203-
Default::default()
2203+
std::ptr::null_mut()
22042204
}
22052205
.cast_const();
22062206
return true;
@@ -2210,7 +2210,7 @@ pub unsafe fn MakeEditableBuffer_43(mut font: *mut woff2_Font, mut tableTag: i32
22102210
let _tag: u32 = (tableTag as u32);
22112211
(*font).FindTable_u32(_tag)
22122212
});
2213-
if ((table) == (Default::default())) {
2213+
if ((table) == (std::ptr::null_mut())) {
22142214
return false;
22152215
}
22162216
if (unsafe { (*table.cast_const()).IsReused() }) {
@@ -2261,14 +2261,14 @@ pub unsafe fn NormalizeGlyphs_44(mut font: *mut woff2_Font) -> bool {
22612261
let _tag: u32 = woff2_kLocaTableTag;
22622262
(*font).FindTable_u32(_tag)
22632263
});
2264-
if ((head_table) == (Default::default())) {
2264+
if ((head_table) == (std::ptr::null_mut())) {
22652265
return false;
22662266
}
2267-
if ((loca_table) == (Default::default())) && ((glyf_table) == (Default::default())) {
2267+
if ((loca_table) == (std::ptr::null_mut())) && ((glyf_table) == (std::ptr::null_mut())) {
22682268
return true;
22692269
}
2270-
if ((((glyf_table) == (Default::default())) as i32)
2271-
!= (((loca_table) == (Default::default())) as i32))
2270+
if ((((glyf_table) == (std::ptr::null_mut())) as i32)
2271+
!= (((loca_table) == (std::ptr::null_mut())) as i32))
22722272
{
22732273
return false;
22742274
}
@@ -2369,10 +2369,10 @@ pub unsafe fn FixChecksums_47(mut font: *mut woff2_Font) -> bool {
23692369
let _tag: u32 = woff2_kHeadTableTag;
23702370
(*font).FindTable_u32(_tag)
23712371
});
2372-
if ((head_table) == (Default::default())) {
2372+
if ((head_table) == (std::ptr::null_mut())) {
23732373
return false;
23742374
}
2375-
if (((*head_table).reuse_of) != (Default::default())) {
2375+
if (((*head_table).reuse_of) != (std::ptr::null_mut())) {
23762376
head_table = (*head_table).reuse_of;
23772377
}
23782378
if (((*head_table).length) < (12_u32)) {
@@ -2425,10 +2425,10 @@ pub unsafe fn MarkTransformed_48(mut font: *mut woff2_Font) -> bool {
24252425
let _tag: u32 = woff2_kHeadTableTag;
24262426
(*font).FindTable_u32(_tag)
24272427
});
2428-
if ((head_table) == (Default::default())) {
2428+
if ((head_table) == (std::ptr::null_mut())) {
24292429
return false;
24302430
}
2431-
if (((*head_table).reuse_of) != (Default::default())) {
2431+
if (((*head_table).reuse_of) != (std::ptr::null_mut())) {
24322432
head_table = (*head_table).reuse_of;
24332433
}
24342434
if (((*head_table).length) < (17_u32)) {
@@ -2971,11 +2971,11 @@ pub unsafe fn TransformGlyfAndLocaTables_56(mut font: *mut woff2_Font) -> bool {
29712971
(*font).FindTable_u32(_tag)
29722972
})
29732973
.cast_const();
2974-
if ((loca_table) == (Default::default())) && ((glyf_table) == (Default::default())) {
2974+
if ((loca_table) == (std::ptr::null())) && ((glyf_table) == (std::ptr::null())) {
29752975
return true;
29762976
}
2977-
if ((((glyf_table) == (Default::default())) as i32)
2978-
!= (((loca_table) == (Default::default())) as i32))
2977+
if ((((glyf_table) == (std::ptr::null())) as i32)
2978+
!= (((loca_table) == (std::ptr::null())) as i32))
29792979
{
29802980
return false;
29812981
}
@@ -3005,7 +3005,7 @@ pub unsafe fn TransformGlyfAndLocaTables_56(mut font: *mut woff2_Font) -> bool {
30053005
let mut i: i32 = 0;
30063006
'loop_: while ((i) < (num_glyphs)) {
30073007
let mut glyph: woff2_Glyph = woff2_Glyph::woff2_Glyph();
3008-
let mut glyph_data: *const u8 = Default::default();
3008+
let mut glyph_data: *const u8 = std::ptr::null();
30093009
let mut glyph_size: u64 = 0_u64;
30103010
if (!(unsafe {
30113011
let _font: *const woff2_Font = &(*font) as *const woff2_Font;
@@ -3039,7 +3039,7 @@ pub unsafe fn TransformGlyfAndLocaTables_56(mut font: *mut woff2_Font) -> bool {
30393039
(*font).FindTable_u32(_tag)
30403040
})
30413041
.cast_const();
3042-
if ((head_table) == (Default::default())) || (((*head_table).length) < (52_u32)) {
3042+
if ((head_table) == (std::ptr::null())) || (((*head_table).length) < (52_u32)) {
30433043
return false;
30443044
}
30453045
(&mut (*transformed_glyf)).buffer[(7_u64) as usize] =
@@ -3049,7 +3049,7 @@ pub unsafe fn TransformGlyfAndLocaTables_56(mut font: *mut woff2_Font) -> bool {
30493049
(*transformed_glyf).data = (*transformed_glyf).buffer.as_mut_ptr().cast_const();
30503050
(*transformed_loca).tag = ((woff2_kLocaTableTag) ^ (2155905152_u32));
30513051
(*transformed_loca).length = 0_u32;
3052-
(*transformed_loca).data = Default::default();
3052+
(*transformed_loca).data = std::ptr::null();
30533053
return true;
30543054
}
30553055
pub unsafe fn TransformHmtxTable_57(mut font: *mut woff2_Font) -> bool {
@@ -3068,10 +3068,10 @@ pub unsafe fn TransformHmtxTable_57(mut font: *mut woff2_Font) -> bool {
30683068
(*font).FindTable_u32(_tag)
30693069
})
30703070
.cast_const();
3071-
if ((hmtx_table) == (Default::default())) || ((glyf_table) == (Default::default())) {
3071+
if ((hmtx_table) == (std::ptr::null())) || ((glyf_table) == (std::ptr::null())) {
30723072
return true;
30733073
}
3074-
if ((hhea_table) == (Default::default())) {
3074+
if ((hhea_table) == (std::ptr::null())) {
30753075
return false;
30763076
}
30773077
let mut hhea_buf: woff2_Buffer =
@@ -3103,7 +3103,7 @@ pub unsafe fn TransformHmtxTable_57(mut font: *mut woff2_Font) -> bool {
31033103
let mut i: i32 = 0;
31043104
'loop_: while ((i) < (num_glyphs)) {
31053105
let mut glyph: woff2_Glyph = woff2_Glyph::woff2_Glyph();
3106-
let mut glyph_data: *const u8 = Default::default();
3106+
let mut glyph_data: *const u8 = std::ptr::null();
31073107
let mut glyph_size: u64 = 0_u64;
31083108
if (!(unsafe {
31093109
let _font: *const woff2_Font = &(*font) as *const woff2_Font;
@@ -3663,7 +3663,7 @@ pub unsafe fn ConvertTTFToWOFF2_73(
36633663
let _tag: u32 = ((tag) ^ (2155905152_u32));
36643664
(*font).FindTable_u32_const(_tag)
36653665
});
3666-
if ((table_to_store) == (Default::default())) {
3666+
if ((table_to_store) == (std::ptr::null())) {
36673667
table_to_store = (original);
36683668
}
36693669
(unsafe {
@@ -3748,7 +3748,7 @@ pub unsafe fn ConvertTTFToWOFF2_73(
37483748
let _tag: u32 = (((*src_table).tag) ^ (2155905152_u32));
37493749
(*font).FindTable_u32_const(_tag)
37503750
});
3751-
if ((transformed_table) != (Default::default())) {
3751+
if ((transformed_table) != (std::ptr::null())) {
37523752
table.flags = ((*transformed_table).flag_byte as u32);
37533753
table.flags = ((table.flags as u32) | woff2_kWoff2FlagsTransform) as u32;
37543754
table.transform_length = (*transformed_table).length;

woff2/out/unsafe/src/bin/woff2_decompress.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ impl woff2_Buffer {
227227
}
228228
pub unsafe fn Skip(&mut self, mut n_bytes: u64) -> bool {
229229
return (unsafe {
230-
let _data: *mut u8 = Default::default();
230+
let _data: *mut u8 = std::ptr::null_mut();
231231
let _n_bytes: u64 = n_bytes;
232232
self.Read(_data, _n_bytes)
233233
});
@@ -1319,7 +1319,7 @@ pub unsafe fn ReconstructGlyf_25(
13191319
substreams[(6_u64) as usize].0,
13201320
substreams[(6_u64) as usize].1,
13211321
);
1322-
let mut overlap_bitmap: *const u8 = Default::default();
1322+
let mut overlap_bitmap: *const u8 = std::ptr::null();
13231323
let mut overlap_bitmap_length: u32 = 0_u32;
13241324
if has_overlap_bitmap {
13251325
overlap_bitmap_length = (((((*info).num_glyphs as i32) + (7)) >> (3)) as u32);
@@ -1774,7 +1774,7 @@ pub unsafe fn FindTable_26(
17741774
return table;
17751775
}
17761776
}
1777-
return Default::default();
1777+
return std::ptr::null_mut();
17781778
}
17791779
pub unsafe fn ReadNumHMetrics_27(
17801780
mut data: *const u8,
@@ -2180,7 +2180,7 @@ pub unsafe fn ReconstructFont_35(
21802180
printf(b"Cannot have just one of glyf/loca\n\0".as_ptr() as *const i8);
21812181
return false;
21822182
}
2183-
if ((glyf_table) != (Default::default())) {
2183+
if ((glyf_table) != (std::ptr::null())) {
21842184
if ((((((*glyf_table).flags) & (woff2_kWoff2FlagsTransform))
21852185
!= (((*loca_table).flags) & (woff2_kWoff2FlagsTransform))) as i64)
21862186
!= 0)

woff2/out/unsafe/src/bin/woff2_info.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ impl woff2_Buffer {
227227
}
228228
pub unsafe fn Skip(&mut self, mut n_bytes: u64) -> bool {
229229
return (unsafe {
230-
let _data: *mut u8 = Default::default();
230+
let _data: *mut u8 = std::ptr::null_mut();
231231
let _n_bytes: u64 = n_bytes;
232232
self.Read(_data, _n_bytes)
233233
});
@@ -696,7 +696,7 @@ impl woff2_Font {
696696
return if it
697697
== UnsafeMapIterator::end(&self.tables as *const BTreeMap<u32, Box<woff2_Font_Table>>)
698698
{
699-
Default::default()
699+
std::ptr::null_mut()
700700
} else {
701701
(&mut *it.second() as *mut woff2_Font_Table)
702702
};
@@ -711,7 +711,7 @@ impl woff2_Font {
711711
return if it
712712
== UnsafeMapIterator::end(&self.tables as *const BTreeMap<u32, Box<woff2_Font_Table>>)
713713
{
714-
Default::default()
714+
std::ptr::null()
715715
} else {
716716
(&*it.second() as *const woff2_Font_Table)
717717
};
@@ -796,7 +796,7 @@ pub unsafe fn ReadTrueTypeFont_15(
796796
'loop_: while ((i as i32) < ((*font).num_tables as i32)) {
797797
let mut table: woff2_Font_Table = <woff2_Font_Table>::default();
798798
table.flag_byte = 0_u8;
799-
table.reuse_of = Default::default();
799+
table.reuse_of = std::ptr::null_mut();
800800
if (((!(unsafe {
801801
let _value: *mut u32 = (&mut table.tag as *mut u32);
802802
(*file).ReadU32(_value)
@@ -846,7 +846,7 @@ pub unsafe fn ReadTrueTypeFont_15(
846846
(*font).FindTable_u32(_tag)
847847
})
848848
.cast_const();
849-
if ((head_table) != (Default::default())) && (((*head_table).length) < (52_u32)) {
849+
if ((head_table) != (std::ptr::null())) && (((*head_table).length) < (52_u32)) {
850850
return false;
851851
}
852852
return true;
@@ -1324,7 +1324,7 @@ pub unsafe fn NumGlyphs_27(font: *const woff2_Font) -> i32 {
13241324
let _tag: u32 = woff2_kLocaTableTag;
13251325
(*font).FindTable_u32_const(_tag)
13261326
});
1327-
if (((head_table) == (Default::default())) || ((loca_table) == (Default::default())))
1327+
if (((head_table) == (std::ptr::null())) || ((loca_table) == (std::ptr::null())))
13281328
|| (((*head_table).length) < (52_u32))
13291329
{
13301330
return 0;
@@ -1345,14 +1345,14 @@ pub unsafe fn IndexFormat_28(font: *const woff2_Font) -> i32 {
13451345
let _tag: u32 = woff2_kHeadTableTag;
13461346
(*font).FindTable_u32_const(_tag)
13471347
});
1348-
if ((head_table) == (Default::default())) {
1348+
if ((head_table) == (std::ptr::null())) {
13491349
return 0;
13501350
}
13511351
return ((*(*head_table).data.offset((51) as isize)) as i32);
13521352
}
13531353
impl woff2_Font_Table {
13541354
pub unsafe fn IsReused(&self) -> bool {
1355-
return ((self.reuse_of) != (Default::default()));
1355+
return ((self.reuse_of) != (std::ptr::null_mut()));
13561356
}
13571357
}
13581358
pub unsafe fn GetGlyphData_29(
@@ -1376,8 +1376,8 @@ pub unsafe fn GetGlyphData_29(
13761376
let _tag: u32 = woff2_kGlyfTableTag;
13771377
(*font).FindTable_u32_const(_tag)
13781378
});
1379-
if ((((head_table) == (Default::default())) || ((loca_table) == (Default::default())))
1380-
|| ((glyf_table) == (Default::default())))
1379+
if ((((head_table) == (std::ptr::null())) || ((loca_table) == (std::ptr::null())))
1380+
|| ((glyf_table) == (std::ptr::null())))
13811381
|| (((*head_table).length) < (52_u32))
13821382
{
13831383
return false;

0 commit comments

Comments
 (0)