diff options
author | mmentovai@google.com <mmentovai@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-08-13 01:17:18 +0000 |
---|---|---|
committer | mmentovai@google.com <mmentovai@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-08-13 01:17:18 +0000 |
commit | 703f427ed4c2e067d95890f8edbbbdc29fc62e1d (patch) | |
tree | 61ec76f580c34d5034a820faf5829b016aa244c3 /base/port.h | |
parent | 856ab444ba32f086519a0db875e716844c060560 (diff) | |
download | chromium_src-703f427ed4c2e067d95890f8edbbbdc29fc62e1d.zip chromium_src-703f427ed4c2e067d95890f8edbbbdc29fc62e1d.tar.gz chromium_src-703f427ed4c2e067d95890f8edbbbdc29fc62e1d.tar.bz2 |
Fix string_util and its tests for the Mac, GCC, UTF-32 wchar_t platforms, and POSIX systems generally.
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@771 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/port.h')
-rw-r--r-- | base/port.h | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/base/port.h b/base/port.h index 12b2a90..885e526 100644 --- a/base/port.h +++ b/base/port.h @@ -27,9 +27,10 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#ifndef BASE_PORT_H__ -#define BASE_PORT_H__ +#ifndef BASE_PORT_H_ +#define BASE_PORT_H_ +#include <stdarg.h> #include "build/build_config.h" #ifdef COMPILER_MSVC @@ -56,4 +57,22 @@ #define GG_UINT32_C(x) (x ## U) #define GG_UINT64_C(x) GG_ULONGLONG(x) -#endif // BASE_PORT_H__ +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); +#elif defined(COMPILER_MSVC) + a = b; +#endif +} + +} // namespace base + +#endif // BASE_PORT_H_ |