Clean up ut_strlcpy(), ut_strlcpy_rev()

ut_strlcpy(): Replace with the standard function strncpy().

ut_strlcpy_rev(): Define in the same compilation unit where
the only caller resides. Avoid unnecessary definition
in non-debug builds.
This commit is contained in:
Marko Mäkelä 2019-10-30 06:42:51 +02:00
commit 44b0c86971
4 changed files with 15 additions and 73 deletions

View file

@ -240,6 +240,17 @@ mem_heap_validate(
ut_ad(size == heap->total_size);
}
/** Copy the tail of a string.
@param[in,out] dst destination buffer
@param[in] src string whose tail to copy
@param[in] size size of dst buffer, in bytes, including NUL terminator
@return strlen(src) */
static void ut_strlcpy_rev(char* dst, const char* src, ulint size)
{
size_t src_size = strlen(src), n = std::min(src_size, size - 1);
memcpy(dst, src + src_size - n, n + 1);
}
#endif /* UNIV_DEBUG */
/***************************************************************//**