diff options
author | Jakob Kaivo <jkk@ung.org> | 2020-09-25 13:30:56 -0400 |
---|---|---|
committer | Jakob Kaivo <jkk@ung.org> | 2020-09-25 13:30:56 -0400 |
commit | b01bb016a28296563cfddb5634726ed51fd720e0 (patch) | |
tree | f44fad060f5d970b6554ced006d66316f360929a /src/string/memmove_s.c | |
parent | 4b0a66869926ab76526e6463a4ff5c741bbd1cc5 (diff) |
get rid of malloc() where possible
Diffstat (limited to 'src/string/memmove_s.c')
-rw-r--r-- | src/string/memmove_s.c | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/src/string/memmove_s.c b/src/string/memmove_s.c index 69bc7208..53e81b45 100644 --- a/src/string/memmove_s.c +++ b/src/string/memmove_s.c @@ -5,15 +5,14 @@ /** move memory **/ errno_t memmove_s(void *s1, rsize_t s1max, const void *s2, rsize_t n) { - __C_EXT(1, 201112L); __ASSERT_NONNULL(s1); __ASSERT_NONNULL(s2); - void *buf = malloc(n); - memcpy(buf, s2, n); - memcpy(s1, buf, n); - free(buf); - return s1; + if (n > s1max) { + /* do the right thing */ + } + + return memmove(s1, s2, n); } /*** |