diff options
author | dzwdz | 2022-08-26 12:19:13 +0200 |
---|---|---|
committer | dzwdz | 2022-08-26 12:19:13 +0200 |
commit | eba8e12e8f0d113056264f71b8cbcda730e93506 (patch) | |
tree | b9d5efa10cfa2d308a7df23a91cf3ea2199950be /src/user/app | |
parent | dc351c97829ef8d15219d90e32101768bd0481be (diff) |
shared: memmove
Diffstat (limited to 'src/user/app')
-rw-r--r-- | src/user/app/tests/libc/string.c | 12 | ||||
-rw-r--r-- | src/user/app/vterm/draw.c | 3 |
2 files changed, 13 insertions, 2 deletions
diff --git a/src/user/app/tests/libc/string.c b/src/user/app/tests/libc/string.c index f865d72..2e00049 100644 --- a/src/user/app/tests/libc/string.c +++ b/src/user/app/tests/libc/string.c @@ -38,6 +38,17 @@ static void test_memset(void) { free(buf); } +static void test_memmove(void) { + const int partsize = 64; + char buf[partsize * 3]; + for (int i = 0; i < partsize * 2; i++) { + memset(buf, 0, sizeof buf); + for (int j = 0; j < partsize; j++) buf[i + j] = j; + memmove(buf + partsize, buf + i, partsize); + for (int j = 0; j < partsize; j++) test(buf[partsize + j] == j); + } +} + static void test_strcmp(void) { test(0 == strcmp("string", "string")); test(0 > strcmp("str", "string")); @@ -102,6 +113,7 @@ static void test_strtok(void) { void r_libc_string(void) { run_test(test_memcmp); run_test(test_memset); + run_test(test_memmove); run_test(test_strcmp); run_test(test_strtol); run_test(test_strspn); diff --git a/src/user/app/vterm/draw.c b/src/user/app/vterm/draw.c index 50c56ed..ee36a0f 100644 --- a/src/user/app/vterm/draw.c +++ b/src/user/app/vterm/draw.c @@ -7,9 +7,8 @@ struct framebuf fb; struct rect dirty; void scroll(void) { - // TODO memmove. this is UD size_t row_len = fb.pitch * font.h; - memcpy(fb.b, fb.b + row_len, fb.len - row_len); + memmove(fb.b, fb.b + row_len, fb.len - row_len); memset(fb.b + fb.len - row_len, 0, row_len); cursor.y--; |