mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-03-14 10:21:49 +00:00
btstack_util: extend btstack_strcpy to return bytes copied
This commit is contained in:
parent
f819d1d921
commit
ed7a067cb2
@ -546,10 +546,11 @@ uint16_t btstack_next_cid_ignoring_zero(uint16_t current_cid){
|
||||
return next_cid;
|
||||
}
|
||||
|
||||
void btstack_strcpy(char * dst, uint16_t dst_size, const char * src){
|
||||
uint16_t bytes_to_copy = (uint16_t) btstack_min( dst_size - 1, (uint32_t) strlen(src));
|
||||
uint16_t btstack_strcpy(char * dst, uint16_t dst_size, const char * src){
|
||||
uint16_t bytes_to_copy = btstack_min( dst_size - 1, strlen(src));
|
||||
(void) memcpy(dst, src, bytes_to_copy);
|
||||
dst[bytes_to_copy] = 0;
|
||||
dst[dst_size-1] = 0;
|
||||
return bytes_to_copy + 1;
|
||||
}
|
||||
|
||||
void btstack_strcat(char * dst, uint16_t dst_size, const char * src){
|
||||
@ -593,4 +594,4 @@ uint16_t btstack_virtual_memcpy(
|
||||
|
||||
memcpy(&buffer[(field_offset + skip_at_start) - buffer_offset], &field_data[skip_at_start], bytes_to_copy);
|
||||
return bytes_to_copy;
|
||||
}
|
||||
}
|
||||
|
@ -322,8 +322,9 @@ uint16_t btstack_next_cid_ignoring_zero(uint16_t current_cid);
|
||||
* @param dst
|
||||
* @param dst_size
|
||||
* @param src
|
||||
* @retun bytes_copied including trailing 0
|
||||
*/
|
||||
void btstack_strcpy(char * dst, uint16_t dst_size, const char * src);
|
||||
uint16_t btstack_strcpy(char * dst, uint16_t dst_size, const char * src);
|
||||
|
||||
/**
|
||||
* @brief Append src string to string in dst buffer with terminating '\0'
|
||||
|
Loading…
x
Reference in New Issue
Block a user