File tree Expand file tree Collapse file tree 4 files changed +11
-6
lines changed
Expand file tree Collapse file tree 4 files changed +11
-6
lines changed Original file line number Diff line number Diff line change @@ -1273,7 +1273,6 @@ def init_arrays_fast(self):
12731273 if f .name == 'FMT' :
12741274 fmt_fmt = f
12751275 break
1276- # fmt_fmt = self.formats['FMT']
12771276 fmt_type = fmt_fmt .type
12781277 type_offset = - 1
12791278 size_offset = - 1
@@ -1292,6 +1291,7 @@ def init_arrays_fast(self):
12921291 offsets = dfindexer .build_offsets (
12931292 data ,
12941293 fmt_type ,
1294+ fmt_fmt .len ,
12951295 type_offset ,
12961296 size_offset ,
12971297 self .HEAD1 ,
Original file line number Diff line number Diff line change @@ -36,13 +36,18 @@ static void ensure_capacity(OffsetArray *arr) {
3636}
3737
3838OffsetArray * scan_offsets (const uint8_t * data , size_t len ,
39- uint8_t fmt_type ,
39+ uint8_t fmt_type , uint8_t fmt_length ,
4040 uint8_t type_offset , uint8_t length_offset ,
4141 uint8_t head1 , uint8_t head2 ) {
4242 uint8_t lengths [NUM_TYPES ] = {0 };
4343 OffsetArray * results = calloc (NUM_TYPES , sizeof (OffsetArray ));
4444 if (!results ) panic ("Memory allocation failed" );
4545
46+ // Make an a-priori assumption about the FMT message length, since
47+ // sometimes, somehow, the FMT for FMT ends up NOT being the first message
48+ // in the file.
49+ lengths [fmt_type ] = fmt_length ;
50+
4651 size_t i = 0 ;
4752 size_t loop_count = 0 ;
4853 while (i + 3 < len ) {
Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ typedef struct OffsetArray {
1111} OffsetArray ;
1212
1313OffsetArray * scan_offsets (const uint8_t * data , size_t len ,
14- uint8_t fmt_type ,
14+ uint8_t fmt_type , uint8_t fmt_length ,
1515 uint8_t type_offset , uint8_t length_offset ,
1616 uint8_t head1 , uint8_t head2 );
1717
Original file line number Diff line number Diff line change @@ -5,22 +5,22 @@ cdef extern from "dfindexer.h":
55 size_t cap
66
77 OffsetArray* scan_offsets(const unsigned char * data, size_t len ,
8- unsigned char fmt_type,
8+ unsigned char fmt_type, unsigned char fmt_length,
99 unsigned char type_offset, unsigned char length_offset,
1010 unsigned char head1, unsigned char head2)
1111
1212 void free_offsets(OffsetArray* offsets)
1313
1414def build_offsets (const unsigned char[:] data ,
15- unsigned char fmt_type ,
15+ unsigned char fmt_type , unsigned char fmt_length ,
1616 unsigned char type_offset , unsigned char length_offset ,
1717 unsigned char head1 , unsigned char head2 ):
1818 cdef OffsetArray* results
1919 cdef size_t i, j
2020 cdef list py_offsets = []
2121
2222 results = scan_offsets(& data[0 ], data.shape[0 ],
23- fmt_type,
23+ fmt_type, fmt_length,
2424 type_offset, length_offset,
2525 head1, head2)
2626 if results == NULL :
You can’t perform that action at this time.
0 commit comments