string_util_posix.h 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. // Copyright 2013 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef BASE_STRINGS_STRING_UTIL_POSIX_H_
  5. #define BASE_STRINGS_STRING_UTIL_POSIX_H_
  6. #include <stdarg.h>
  7. #include <stddef.h>
  8. #include <stdio.h>
  9. #include <string.h>
  10. #include <wchar.h>
  11. #include "base/logging.h"
  12. namespace base {
  13. // Chromium code style is to not use malloc'd strings; this is only for use
  14. // for interaction with APIs that require it.
  15. inline char* strdup(const char* str) {
  16. return ::strdup(str);
  17. }
  18. inline int vsnprintf(char* buffer, size_t size,
  19. const char* format, va_list arguments) {
  20. return ::vsnprintf(buffer, size, format, arguments);
  21. }
  22. inline int vswprintf(wchar_t* buffer, size_t size,
  23. const wchar_t* format, va_list arguments) {
  24. DCHECK(IsWprintfFormatPortable(format));
  25. return ::vswprintf(buffer, size, format, arguments);
  26. }
  27. } // namespace base
  28. #endif // BASE_STRINGS_STRING_UTIL_POSIX_H_