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