diff options
author | deanm@chromium.org <deanm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-27 21:12:05 +0000 |
---|---|---|
committer | deanm@chromium.org <deanm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-27 21:12:05 +0000 |
commit | 16e97f777a9429b2a0fde3a7982ff393b41e72ee (patch) | |
tree | 4ceab0956d92c7ead6f3211dac8a24e8f9d65505 /base | |
parent | 3dd7a7a7806269c92861cbeb073dac8291d80e35 (diff) | |
download | chromium_src-16e97f777a9429b2a0fde3a7982ff393b41e72ee.zip chromium_src-16e97f777a9429b2a0fde3a7982ff393b41e72ee.tar.gz chromium_src-16e97f777a9429b2a0fde3a7982ff393b41e72ee.tar.bz2 |
Move base::va_copy from a function to a macro.
va_copy is a builtin, you can't just pass it references like we did previously.
Review URL: http://codereview.chromium.org/160191
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@21706 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base')
-rw-r--r-- | base/port.h | 10 | ||||
-rw-r--r-- | base/string_util.cc | 4 | ||||
-rw-r--r-- | base/string_util_unittest.cc | 2 |
3 files changed, 5 insertions, 11 deletions
diff --git a/base/port.h b/base/port.h index d077705..18a9361 100644 --- a/base/port.h +++ b/base/port.h @@ -32,23 +32,17 @@ #define GG_UINT32_C(x) (x ## U) #define GG_UINT64_C(x) GG_ULONGLONG(x) -namespace base { - // It's possible for functions that use a va_list, such as StringPrintf, to // invalidate the data in it upon use. The fix is to make a copy of the // structure before using it and use that copy instead. va_copy is provided // for this purpose. MSVC does not provide va_copy, so define an // implementation here. It is not guaranteed that assignment is a copy, so the // StringUtil.VariableArgsFunc unit test tests this capability. -inline void va_copy(va_list& a, va_list& b) { #if defined(COMPILER_GCC) - ::va_copy(a, b); +#define GG_VA_COPY(a, b) (va_copy(a, b)) #elif defined(COMPILER_MSVC) - a = b; +#define GG_VA_COPY(a, b) (a = b) #endif -} - -} // namespace base // Define an OS-neutral wrapper for shared library entry points #if defined(OS_WIN) diff --git a/base/string_util.cc b/base/string_util.cc index 2699f26..2f20d78 100644 --- a/base/string_util.cc +++ b/base/string_util.cc @@ -915,7 +915,7 @@ static void StringAppendVT(StringType* dst, typename StringType::value_type stack_buf[1024]; va_list backup_ap; - base::va_copy(backup_ap, ap); + GG_VA_COPY(backup_ap, ap); #if !defined(OS_WIN) errno = 0; @@ -962,7 +962,7 @@ static void StringAppendVT(StringType* dst, std::vector<typename StringType::value_type> mem_buf(mem_length); // Restore the va_list before we use it again. - base::va_copy(backup_ap, ap); + GG_VA_COPY(backup_ap, ap); result = vsnprintfT(&mem_buf[0], mem_length, format, ap); va_end(backup_ap); diff --git a/base/string_util_unittest.cc b/base/string_util_unittest.cc index 4968950..35c58d6 100644 --- a/base/string_util_unittest.cc +++ b/base/string_util_unittest.cc @@ -1302,7 +1302,7 @@ static void VariableArgsFunc(const char* format, ...) { va_start(org, format); va_list dup; - base::va_copy(dup, org); + GG_VA_COPY(dup, org); int i1 = va_arg(org, int); int j1 = va_arg(org, int); char* s1 = va_arg(org, char*); |