| OLD | NEW |
| 1 // Copyright 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright 2006-2008 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef MINI_CHROMIUM_BASE_STRINGS_STRING_UTIL_H_ | 5 #ifndef MINI_CHROMIUM_BASE_STRINGS_STRING_UTIL_H_ |
| 6 #define MINI_CHROMIUM_BASE_STRINGS_STRING_UTIL_H_ | 6 #define MINI_CHROMIUM_BASE_STRINGS_STRING_UTIL_H_ |
| 7 | 7 |
| 8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 | 10 |
| 11 namespace base { | 11 namespace base { |
| 12 | 12 |
| 13 int vsnprintf(char* buffer, size_t size, const char* format, va_list arguments) | 13 int vsnprintf(char* buffer, size_t size, const char* format, va_list arguments) |
| 14 PRINTF_FORMAT(3, 0); | 14 PRINTF_FORMAT(3, 0); |
| 15 | 15 |
| 16 } // namespace base | 16 } // namespace base |
| 17 | 17 |
| 18 #if defined(OS_POSIX) | 18 #if defined(OS_WIN) |
| 19 #include "base/strings/string_util_win.h" |
| 20 #elif defined(OS_POSIX) |
| 19 #include "base/strings/string_util_posix.h" | 21 #include "base/strings/string_util_posix.h" |
| 20 #endif | 22 #endif |
| 21 | 23 |
| 22 template <class string_type> | 24 template <class string_type> |
| 23 inline typename string_type::value_type* WriteInto(string_type* str, | 25 inline typename string_type::value_type* WriteInto(string_type* str, |
| 24 size_t length_with_null) { | 26 size_t length_with_null) { |
| 25 DCHECK_NE(0u, length_with_null); | 27 DCHECK_NE(0u, length_with_null); |
| 26 str->reserve(length_with_null); | 28 str->reserve(length_with_null); |
| 27 str->resize(length_with_null - 1); | 29 str->resize(length_with_null - 1); |
| 28 | 30 |
| 29 if (length_with_null <= 1) | 31 if (length_with_null <= 1) |
| 30 return NULL; | 32 return NULL; |
| 31 | 33 |
| 32 return &((*str)[0]); | 34 return &((*str)[0]); |
| 33 } | 35 } |
| 34 | 36 |
| 35 #endif // MINI_CHROMIUM_BASE_STRINGS_STRING_UTIL_H_ | 37 #endif // MINI_CHROMIUM_BASE_STRINGS_STRING_UTIL_H_ |
| OLD | NEW |