summaryrefslogtreecommitdiff
path: root/include/inspircd.h
diff options
context:
space:
mode:
authorPeter Powell <petpow@saberuk.com>2013-05-19 02:53:32 +0100
committerPeter Powell <petpow@saberuk.com>2013-06-06 01:45:04 +0100
commit955ad16ed79016a637101f81ed23160014dc13f9 (patch)
tree97d5f693e87cb8c2a851014e79c9ad401b87c9c8 /include/inspircd.h
parentc68baddf6cf05e22dd25a563e35b1e4533ee7047 (diff)
Convert ConvNumeric() to use std::string instead of char[MAXBUF].
Diffstat (limited to 'include/inspircd.h')
-rw-r--r--include/inspircd.h19
1 files changed, 9 insertions, 10 deletions
diff --git a/include/inspircd.h b/include/inspircd.h
index 957032da2..f86945903 100644
--- a/include/inspircd.h
+++ b/include/inspircd.h
@@ -82,20 +82,19 @@ CoreExport extern InspIRCd* ServerInstance;
*/
template<typename T> inline std::string ConvNumeric(const T &in)
{
- if (in == 0) return "0";
- char res[MAXBUF];
- char* out = res;
+ if (in == 0)
+ return "0";
T quotient = in;
- while (quotient) {
- *out = "0123456789"[ std::abs( (long)quotient % 10 ) ];
- ++out;
+ std::string out;
+ while (quotient)
+ {
+ out += "0123456789"[ std::abs( (long)quotient % 10 ) ];
quotient /= 10;
}
if (in < 0)
- *out++ = '-';
- *out = 0;
- std::reverse(res,out);
- return res;
+ out += '-';
+ std::reverse(out.begin(), out.end());
+ return out;
}
/** Template function to convert any input type to std::string