//exit(5);
}
- const unsigned char *iso_start = xfr->buffer + offset;
- for (unsigned iso_offset = 0; iso_offset < pack->actual_length; ) { // Usually runs only one iteration.
- const unsigned char* start_next_frame = (const unsigned char *)memmem(iso_start + iso_offset, pack->actual_length - iso_offset, sync_pattern, sync_length);
+ const uint8_t *start = xfr->buffer + offset;
+ const uint8_t *limit = start + pack->actual_length;
+ while (start < limit) { // Usually runs only one iteration.
+ const unsigned char* start_next_frame = (const unsigned char *)memmem(start, limit - start, sync_pattern, sync_length);
if (start_next_frame == nullptr) {
// add the rest of the buffer
- const uint8_t *start = iso_start + iso_offset;
- const uint8_t *end = iso_start + pack->actual_length;
- add_to_frame(current_frame, frame_type_name, start, end);
+ add_to_frame(current_frame, frame_type_name, start, limit);
break;
} else {
- const uint8_t *start = iso_start + iso_offset;
- const uint8_t *end = start_next_frame;
- add_to_frame(current_frame, frame_type_name, start, end);
- start_callback(start_next_frame + sync_length);
-
- int suboffset = start_next_frame - iso_start;
- iso_offset = suboffset + sync_length; // skip sync
+ add_to_frame(current_frame, frame_type_name, start, start_next_frame);
+ start = start_next_frame + sync_length; // skip sync
+ start_callback(start);
}
}
#if 0