From 955ad16ed79016a637101f81ed23160014dc13f9 Mon Sep 17 00:00:00 2001 From: Peter Powell Date: Sun, 19 May 2013 02:53:32 +0100 Subject: Convert ConvNumeric() to use std::string instead of char[MAXBUF]. --- include/inspircd.h | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'include/inspircd.h') 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 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 -- cgit v1.2.3