This is an automated email from the ASF dual-hosted git repository. xiaoxiang781216 pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit 1930658de9ef23dea5c4aec60c94699971e2789a Author: chao an <[email protected]> AuthorDate: Mon Oct 26 14:17:39 2026 +0800 libs/libc/ncompress: Use memmove() to compact input Use memmove() when compacting the ncompress input buffer after consuming a byte-aligned prefix. The source and destination ranges are in the same buffer, so memmove() expresses the overlapping-copy semantics that the byte loop implemented. Keep the non-zero length guard so the call is skipped when no buffered input remains. This lets the C library use an optimized block move while preserving the existing decoder state updates. Signed-off-by: chao an <[email protected]> --- libs/libc/misc/lib_ncompress.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libs/libc/misc/lib_ncompress.c b/libs/libc/misc/lib_ncompress.c index 0117a93bf0c..9c4b3768ffe 100644 --- a/libs/libc/misc/lib_ncompress.c +++ b/libs/libc/misc/lib_ncompress.c @@ -779,15 +779,15 @@ void decompress(int fdin, int fdout) { resetbuf:; { - int i; int e; int o; o = posbits >> 3; e = o <= insize ? insize - o : 0; - - for (i = 0; i < e; ++i) - inbuf[i] = inbuf[i + o]; + if (e > 0) + { + memmove(inbuf, inbuf + o, e); + } insize = e; posbits = 0;
