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:
dongjiuzhu1 2023-02-27 17:34:15 +08:00 committed by Xiang Xiao
parent b178ce4da9
commit 81825bc003
1 changed files with 2 additions and 1 deletions

View File

@ -526,6 +526,7 @@ ssize_t circbuf_overwrite(FAR struct circbuf_s *circ,
overwrite = bytes - space + skip;
}
circ->head += skip;
off = circ->head % circ->size;
space = circ->size - off;
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(circ->base, (FAR char *)src + space, bytes - space);
circ->head += bytes + skip;
circ->head += bytes;
circ->tail += overwrite;
return overwrite;