From b01bb016a28296563cfddb5634726ed51fd720e0 Mon Sep 17 00:00:00 2001 From: Jakob Kaivo Date: Fri, 25 Sep 2020 13:30:56 -0400 Subject: get rid of malloc() where possible --- src/string/memmove_s.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'src/string') 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); } /*** -- cgit v1.2.1