uint16_t index = M_index;
uint8_t end_or_hole_found = 0;
- for (;;)
+ while (index != this_fragmentation->start_index)
{
fragmentt *this_frag;
// before a MP_BEGIN, there must be a MP_END
if (front_frag->length && (front_frag->flags & MP_BEGIN))
+ {
end_or_hole_found = 1;
+ end_index = index;
+ }
+ }
- index = (index + (MAXFRAGNUM-1)) & MAXFRAGNUM_MASK;
- this_frag = &this_fragmentation->frag[index];
+ index = (index + (MAXFRAGNUM-1)) & MAXFRAGNUM_MASK;
+ this_frag = &this_fragmentation->frag[index];
+ if (!end_or_hole_found)
+ {
// we are a hole or a MP_END
if (!this_frag->length || (this_frag->flags & MP_END))
+ {
end_or_hole_found = 1;
-
- if (end_or_hole_found)
end_index = index;
+ }
}
if (end_or_hole_found)
this_frag->flags = 0;
this_frag->length = 0;
}
-
- if (index == this_fragmentation->start_index)
- break;
}
this_fragmentation->start_index = (end_index + 1) & MAXFRAGNUM_MASK;