string_util_posix.h 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738
  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/check.h"
  12. #include "base/strings/string_piece.h"
  13. namespace base {
  14. // Chromium code style is to not use malloc'd strings; this is only for use
  15. // for interaction with APIs that require it.
  16. inline char* strdup(const char* str) {
  17. return ::strdup(str);
  18. }
  19. inline int vsnprintf(char* buffer, size_t size,
  20. const char* format, va_list arguments) {
  21. return ::vsnprintf(buffer, size, format, arguments);
  22. }
  23. inline int vswprintf(wchar_t* buffer, size_t size,
  24. const wchar_t* format, va_list arguments) {
  25. DCHECK(IsWprintfFormatPortable(format));
  26. return ::vswprintf(buffer, size, format, arguments);
  27. }
  28. } // namespace base
  29. #endif // BASE_STRINGS_STRING_UTIL_POSIX_H_