* new StrHelper::strzcpy()

Tento commit je obsažen v:
Scott Powell
2025-02-22 20:10:31 +11:00
rodič 37f4ceff85
revize fc4e5ed54c
4 změnil soubory, kde provedl 13 přidání a 3 odebrání
+11
Zobrazit soubor
@@ -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--;
}
}
+1
Zobrazit soubor
@@ -10,4 +10,5 @@
class StrHelper {
public:
static void strncpy(char* dest, const char* src, size_t buf_sz);
static void strzcpy(char* dest, const char* src, size_t buf_sz); // pads with trailing nulls
};