mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-01-30 15:32:41 +00:00
btstack_util: add btstack_strcpy
This commit is contained in:
parent
09f429629a
commit
de22414a4c
@ -489,3 +489,9 @@ 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 = btstack_min( dst_size - 1, strlen(src));
|
||||
(void) memcpy(dst, src, bytes_to_copy);
|
||||
dst[dst_size-1] = 0;
|
||||
}
|
||||
|
@ -302,6 +302,15 @@ uint8_t btstack_crc8_calc(uint8_t * data, uint16_t len);
|
||||
*/
|
||||
uint16_t btstack_next_cid_ignoring_zero(uint16_t current_cid);
|
||||
|
||||
/**
|
||||
* @brief Copy string (up to dst_size-1 characters) from src into dst buffer with terminating '\0'
|
||||
* @note replaces strncpy + dst[dst_size-1] = '\0'
|
||||
* @param dst
|
||||
* @param dst_size
|
||||
* @param src
|
||||
*/
|
||||
void btstack_strcpy(char * dst, uint16_t dst_size, const char * src);
|
||||
|
||||
/* API_END */
|
||||
|
||||
#if defined __cplusplus
|
||||
|
Loading…
x
Reference in New Issue
Block a user