From 830572b91f2199167b234a08c3c2227a5049efeb Mon Sep 17 00:00:00 2001 From: Kevin Easton Date: Tue, 27 Nov 2018 17:26:53 +1100 Subject: [PATCH] Simplify and improve ov_strcpy() The new implementation calls into strlen() and memmove(), and is safe to use even if the arguments don't point into the same string. The return value is now the same as the first argument (just like strcpy()), but no existing callers care about the return value anyway. --- source/ircaux.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/source/ircaux.c b/source/ircaux.c index 11a2508..b99c552 100644 --- a/source/ircaux.c +++ b/source/ircaux.c @@ -2332,17 +2332,11 @@ char *BX_strmopencat (char *dest, int maxlen, ...) } /* - * An strcpy that is guaranteed to be safe for overlaps. + * A strcpy that is guaranteed to be safe for overlaps. */ char *BX_ov_strcpy (char *one, const char *two) { - if (two > one) - { - while (two && *two) - *one++ = *two++; - *one = 0; - } - return one; + return memmove(one, two, strlen(two) + 1); } char *BX_next_in_comma_list (char *str, char **after)