summaryrefslogtreecommitdiff
path: root/src/helperfuncs.cpp
diff options
context:
space:
mode:
authorDaniel Vassdal <shutter@canternet.org>2013-05-18 11:31:25 -0700
committerDaniel Vassdal <shutter@canternet.org>2013-05-18 14:01:21 -0700
commit42ae4790815734dca6357d3b69f2aca604316aa3 (patch)
tree3e95c0c32a43ce6756269888fc02f2df7307bba0 /src/helperfuncs.cpp
parent3ce33ee0e6bc0b8fbe2a564a37e02d2e56510b06 (diff)
Added macro to allow simpler logic in functions with the need to vsnprintf
Diffstat (limited to 'src/helperfuncs.cpp')
-rw-r--r--src/helperfuncs.cpp13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/helperfuncs.cpp b/src/helperfuncs.cpp
index d11a13aa0..c097b0033 100644
--- a/src/helperfuncs.cpp
+++ b/src/helperfuncs.cpp
@@ -424,19 +424,22 @@ unsigned long InspIRCd::Duration(const std::string &str)
return total + subtotal;
}
-const char* InspIRCd::Format(const char* formatString, ...)
+const char* InspIRCd::Format(const va_list &vaList, const char* formatString)
{
static std::vector<char> formatBuffer(1024);
int vsnret = 0;
-
- va_list vaList;
- va_start(vaList, formatString);
while ((vsnret = vsnprintf(&formatBuffer[0], formatBuffer.size(), formatString, vaList)) < 0 || static_cast<unsigned int>(vsnret) >= formatBuffer.size())
formatBuffer.resize(formatBuffer.size() * 2);
- va_end(vaList);
return &formatBuffer[0];
}
+const char* InspIRCd::Format(const char* formatString, ...)
+{
+ const char* ret;
+ VAFORMAT(ret, formatString, formatString);
+ return ret;
+}
+
bool InspIRCd::ULine(const std::string& sserver)
{
if (sserver.empty())