btstack_util: add btstack_strcat

This commit is contained in:
Matthias Ringwald 2022-04-29 11:20:12 +02:00
parent 8d3d774439
commit 3ece47889a
2 changed files with 17 additions and 0 deletions

View File

@ -499,3 +499,11 @@ void btstack_strcpy(char * dst, uint16_t dst_size, const char * src){
(void) memcpy(dst, src, bytes_to_copy);
dst[bytes_to_copy] = 0;
}
void btstack_strcat(char * dst, uint16_t dst_size, const char * src){
uint16_t src_len = (uint16_t) strlen(src);
uint16_t dst_len = (uint16_t) strlen(dst);
uint16_t bytes_to_copy = btstack_min( src_len, dst_size - dst_len - 1);
(void) memcpy( &dst[dst_len], src, bytes_to_copy);
dst[dst_len + bytes_to_copy] = 0;
}

View File

@ -319,6 +319,15 @@ uint16_t btstack_next_cid_ignoring_zero(uint16_t current_cid);
*/
void btstack_strcpy(char * dst, uint16_t dst_size, const char * src);
/**
* @brief Append src string to string in dst buffer with terminating '\0'
* @note max total string length will be dst_size-1 characters
* @param dst
* @param dst_size
* @param src
*/
void btstack_strcat(char * dst, uint16_t dst_size, const char * src);
/* API_END */
#if defined __cplusplus