diff options
Diffstat (limited to 'cores')
-rw-r--r-- | cores/arduino/WString.cpp | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/cores/arduino/WString.cpp b/cores/arduino/WString.cpp index 8b6eabe..ed880ce 100644 --- a/cores/arduino/WString.cpp +++ b/cores/arduino/WString.cpp @@ -21,7 +21,6 @@ #include "WString.h" - /*********************************************/ /* Constructors */ /*********************************************/ @@ -69,7 +68,7 @@ String::String(char c) String::String(unsigned char value, unsigned char base) { init(); - char buf[9]; + char buf[1 + 8 * sizeof(unsigned char)]; utoa(value, buf, base); *this = buf; } @@ -77,7 +76,7 @@ String::String(unsigned char value, unsigned char base) String::String(int value, unsigned char base) { init(); - char buf[18]; + char buf[2 + 8 * sizeof(int)]; itoa(value, buf, base); *this = buf; } @@ -85,7 +84,7 @@ String::String(int value, unsigned char base) String::String(unsigned int value, unsigned char base) { init(); - char buf[17]; + char buf[1 + 8 * sizeof(unsigned int)]; utoa(value, buf, base); *this = buf; } @@ -93,7 +92,7 @@ String::String(unsigned int value, unsigned char base) String::String(long value, unsigned char base) { init(); - char buf[34]; + char buf[2 + 8 * sizeof(long)]; ltoa(value, buf, base); *this = buf; } @@ -101,7 +100,7 @@ String::String(long value, unsigned char base) String::String(unsigned long value, unsigned char base) { init(); - char buf[33]; + char buf[1 + 8 * sizeof(unsigned long)]; ultoa(value, buf, base); *this = buf; } @@ -288,35 +287,35 @@ unsigned char String::concat(char c) unsigned char String::concat(unsigned char num) { - char buf[4]; + char buf[1 + 3 * sizeof(unsigned char)]; itoa(num, buf, 10); return concat(buf, strlen(buf)); } unsigned char String::concat(int num) { - char buf[12]; + char buf[2 + 3 * sizeof(int)]; itoa(num, buf, 10); return concat(buf, strlen(buf)); } unsigned char String::concat(unsigned int num) { - char buf[11]; + char buf[1 + 3 * sizeof(unsigned int)]; utoa(num, buf, 10); return concat(buf, strlen(buf)); } unsigned char String::concat(long num) { - char buf[12]; + char buf[2 + 3 * sizeof(long)]; ltoa(num, buf, 10); return concat(buf, strlen(buf)); } unsigned char String::concat(unsigned long num) { - char buf[11]; + char buf[1 + 3 * sizeof(unsigned long)]; ultoa(num, buf, 10); return concat(buf, strlen(buf)); } |