diff options
-rw-r--r-- | src/FbTk/StringUtil.cc | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/FbTk/StringUtil.cc b/src/FbTk/StringUtil.cc index 00d2e88..9cd2c9a 100644 --- a/src/FbTk/StringUtil.cc +++ b/src/FbTk/StringUtil.cc | |||
@@ -69,6 +69,9 @@ using std::transform; | |||
69 | 69 | ||
70 | namespace { | 70 | namespace { |
71 | 71 | ||
72 | const size_t DIGITS10_ULONGLONGINT = 20; // ULLONG_MAX = 18446744073709551615 | ||
73 | const size_t DIGITS16_ULONGLONGINT = 18; // ULLONG_MAX = 0xffffffffffffffff | ||
74 | |||
72 | template <typename T> | 75 | template <typename T> |
73 | int extractBigNumber(const char* in, T (*extractFunc)(const char*, char**, int), T& out) { | 76 | int extractBigNumber(const char* in, T (*extractFunc)(const char*, char**, int), T& out) { |
74 | 77 | ||
@@ -170,14 +173,14 @@ int extractNumber(const std::string& in, unsigned long long& out) { | |||
170 | 173 | ||
171 | 174 | ||
172 | std::string number2String(long long num) { | 175 | std::string number2String(long long num) { |
173 | char s[128]; | 176 | char s[DIGITS10_ULONGLONGINT]; |
174 | snprintf(s, sizeof(s), "%lld", num); | 177 | snprintf(s, sizeof(s), "%lld", num); |
175 | return std::string(s); | 178 | return std::string(s); |
176 | } | 179 | } |
177 | 180 | ||
178 | std::string number2HexString(long long num) { | 181 | std::string number2HexString(long long num) { |
179 | char s[17]; | 182 | char s[DIGITS16_ULONGLONGINT]; |
180 | snprintf(s, sizeof(s), "%lx", num); | 183 | snprintf(s, sizeof(s), "%llx", num); |
181 | return std::string(s); | 184 | return std::string(s); |
182 | } | 185 | } |
183 | 186 | ||