mirror of
https://github.com/varun-r-mallya/sysprof.git
synced 2025-12-31 20:36:25 +00:00
libsysprof-capture: Use strlcpy() instead of g_strlcpy()
If the system doesn’t provide `strlcpy()` (FreeBSD does, Linux doesn’t), use an inbuilt copy instead. Signed-off-by: Philip Withnall <withnall@endlessm.com> Helps: #40
This commit is contained in:
@ -236,3 +236,23 @@ ssize_t
|
||||
errno = 0;
|
||||
return total;
|
||||
}
|
||||
|
||||
size_t
|
||||
(_sysprof_strlcpy) (char *dest,
|
||||
const char *src,
|
||||
size_t dest_size)
|
||||
{
|
||||
size_t i = 0;
|
||||
|
||||
if (dest_size > 0)
|
||||
{
|
||||
for (; i < dest_size - 1 && src[i] != '\0'; i++)
|
||||
dest[i] = src[i];
|
||||
dest[i] = '\0';
|
||||
}
|
||||
|
||||
for (; src[i] != '\0'; i++)
|
||||
;
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user