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:
parent
e51469568e
commit
830572b91f
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue