* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ * along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
#include <config.h>
{
struct scale_info *scale;
struct dev_context *devc;
- int len, i, offset = 0;
+ int len, offset;
struct sr_serial_dev_inst *serial;
scale = (struct scale_info *)sdi->driver;
devc->buflen += len;
/* Now look for packets in that data. */
+ offset = 0;
while ((devc->buflen - offset) >= scale->packet_size) {
if (scale->packet_valid(devc->buf + offset)) {
handle_packet(devc->buf + offset, sdi, info);
}
/* If we have any data left, move it to the beginning of our buffer. */
- for (i = 0; i < devc->buflen - offset; i++)
- devc->buf[i] = devc->buf[offset + i];
+ if (offset < devc->buflen)
+ memmove(devc->buf, devc->buf + offset, devc->buflen - offset);
devc->buflen -= offset;
}
}
if (sr_sw_limits_check(&devc->limits))
- sdi->driver->dev_acquisition_stop(sdi);
+ sr_dev_acquisition_stop(sdi);
return TRUE;
}