mirror of
https://github.com/meshcore-dev/MeshCore.git
synced 2026-04-20 22:13:47 +00:00
* new StrHelper::strzcpy()
This commit is contained in:
parent
37f4ceff85
commit
fc4e5ed54c
4 changed files with 13 additions and 3 deletions
|
|
@ -7,3 +7,14 @@ void StrHelper::strncpy(char* dest, const char* src, size_t buf_sz) {
|
|||
}
|
||||
*dest = 0; // truncates if needed
|
||||
}
|
||||
|
||||
void StrHelper::strzcpy(char* dest, const char* src, size_t buf_sz) {
|
||||
while (buf_sz > 1 && *src) {
|
||||
*dest++ = *src++;
|
||||
buf_sz--;
|
||||
}
|
||||
while (buf_sz > 0) { // pad remaining with nulls
|
||||
*dest++ = 0;
|
||||
buf_sz--;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue