On Fri, May 24, 2019 at 01:16:07PM +0200, Daniel Lezcano wrote: > The current code was luckily working with most of the interval samples > testing but actually it fails to correctly detect pattern repeatition > breaking at the end of the buffer. > > Narrowing down the bug has been a real pain because of the pointers, > so the routine is rewrite by using indexes instead.
Minor spelling issues below. > + /* > + * Move the beginnning pointer to the end minus the max period Typo: beginning. > + * x 3. We are at the point we can begin searching the pattern "x 3." would be read better on the previous line. > + */ > + buffer = &buffer[len - (period_max * 3)]; > + /* > + * Adjust the length to the maximum allowed period x 3 > + */ One line? > + len = period_max * 3; > - for (i = period_max; i >= PREDICTION_PERIOD_MIN ; i--) { > + for (period = period_max; period >= PREDICTION_PERIOD_MIN ; period--) { At the same time you may drop extra white space. > } -- With Best Regards, Andy Shevchenko