aboutsummaryrefslogtreecommitdiff
path: root/src/util.cpp
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2011-06-13 16:56:37 +0200
committerWladimir J. van der Laan <laanwj@gmail.com>2011-06-13 16:56:37 +0200
commit39cf857db9b926c47f545cba1d7113267260c40e (patch)
tree8aa3a7fbfa8079e7837650c8c3f0e9032ba87df4 /src/util.cpp
parente83474f2ebbae84394f0b86cfea977d3024bd33f (diff)
Internationalization -- initial step, make _ return a std::string to prevent memory leaks
Diffstat (limited to 'src/util.cpp')
-rw-r--r--src/util.cpp10
1 files changed, 4 insertions, 6 deletions
diff --git a/src/util.cpp b/src/util.cpp
index 6199109289..fd4a9e459c 100644
--- a/src/util.cpp
+++ b/src/util.cpp
@@ -255,8 +255,7 @@ int my_snprintf(char* buffer, size_t limit, const char* format, ...)
return ret;
}
-
-string strprintf(const char* format, ...)
+string strprintf(const std::string &format, ...)
{
char buffer[50000];
char* p = buffer;
@@ -266,7 +265,7 @@ string strprintf(const char* format, ...)
{
va_list arg_ptr;
va_start(arg_ptr, format);
- ret = _vsnprintf(p, limit, format, arg_ptr);
+ ret = _vsnprintf(p, limit, format.c_str(), arg_ptr);
va_end(arg_ptr);
if (ret >= 0 && ret < limit)
break;
@@ -283,14 +282,13 @@ string strprintf(const char* format, ...)
return str;
}
-
-bool error(const char* format, ...)
+bool error(const std::string &format, ...)
{
char buffer[50000];
int limit = sizeof(buffer);
va_list arg_ptr;
va_start(arg_ptr, format);
- int ret = _vsnprintf(buffer, limit, format, arg_ptr);
+ int ret = _vsnprintf(buffer, limit, format.c_str(), arg_ptr);
va_end(arg_ptr);
if (ret < 0 || ret >= limit)
{