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.
This commit is contained in:
Kevin Easton 2018-11-27 17:26:53 +11:00
parent e51469568e
commit 830572b91f
1 changed files with 2 additions and 8 deletions

View File

@ -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)