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 PARTITION_ALLOC_PARTITION_ALLOC_BASE_STRINGS_STRINGPRINTF_H_ 6 #define PARTITION_ALLOC_PARTITION_ALLOC_BASE_STRINGS_STRINGPRINTF_H_ 7 8 #include <cstdarg> // va_list 9 #include <string> 10 11 #include "build/build_config.h" 12 #include "partition_alloc/partition_alloc_base/compiler_specific.h" 13 #include "partition_alloc/partition_alloc_base/component_export.h" 14 15 namespace partition_alloc::internal::base { 16 17 // Since Only SystemErrorCodeToString and partition_alloc_perftests use 18 // StringPrintf, make StringPrintf not to support too long results. 19 // Instead, define max result length and truncate such results. 20 static constexpr size_t kMaxLengthOfTruncatingStringPrintfResult = 255U; 21 22 // Return a C++ string given printf-like input. 23 [[nodiscard]] PA_COMPONENT_EXPORT(PARTITION_ALLOC_BASE) std::string 24 TruncatingStringPrintf(const char* format, ...) PA_PRINTF_FORMAT(1, 2); 25 26 } // namespace partition_alloc::internal::base 27 28 #endif // PARTITION_ALLOC_PARTITION_ALLOC_BASE_STRINGS_STRINGPRINTF_H_ 29