Don't copy if *ptr is NULL. Can be used to skip past data in the stream.

master
Philip Heron 2010-08-09 17:03:14 +01:00
rodzic 3af237b5d6
commit d238915f38
1 zmienionych plików z 6 dodań i 3 usunięć

9
c328.c
Wyświetl plik

@ -251,7 +251,7 @@ char c3_close(void)
uint16_t c3_read(uint8_t *ptr, uint16_t length)
{
uint16_t r;
uint16_t r; /* Number of bytes left to read */
/* Don't read past the end of the image */
r = image_len - image_read;
@ -274,12 +274,15 @@ uint16_t c3_read(uint8_t *ptr, uint16_t length)
uint16_t b = r;
if(b > package_len) b = package_len;
memcpy(ptr, package, b);
if(ptr)
{
memcpy(ptr, package, b);
ptr += b;
}
package += b;
package_len -= b;
ptr += b;
r -= b;
image_read += b;