mirror of
https://github.com/apache/nuttx.git
synced 2026-06-05 15:58:59 +08:00
mm/circbuf: fix minor issue about update buffer head
update head pointer with skip before write buffer. Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
This commit is contained in:
@@ -526,6 +526,7 @@ ssize_t circbuf_overwrite(FAR struct circbuf_s *circ,
|
|||||||
overwrite = bytes - space + skip;
|
overwrite = bytes - space + skip;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
circ->head += skip;
|
||||||
off = circ->head % circ->size;
|
off = circ->head % circ->size;
|
||||||
space = circ->size - off;
|
space = circ->size - off;
|
||||||
if (bytes < space)
|
if (bytes < space)
|
||||||
@@ -535,7 +536,7 @@ ssize_t circbuf_overwrite(FAR struct circbuf_s *circ,
|
|||||||
|
|
||||||
memcpy((FAR char *)circ->base + off, src, space);
|
memcpy((FAR char *)circ->base + off, src, space);
|
||||||
memcpy(circ->base, (FAR char *)src + space, bytes - space);
|
memcpy(circ->base, (FAR char *)src + space, bytes - space);
|
||||||
circ->head += bytes + skip;
|
circ->head += bytes;
|
||||||
circ->tail += overwrite;
|
circ->tail += overwrite;
|
||||||
|
|
||||||
return overwrite;
|
return overwrite;
|
||||||
|
|||||||
Reference in New Issue
Block a user