Revert "Change SimpleStringBuilder::Append to not use strcpyn and SIZE_UNKNOWN"
This reverts commit e779847fb6499ac2dc4757de8c625ac377e9d0d4. Reason for revert: Breaks downstream projects, depending on indirect include. Original change's description: > Change SimpleStringBuilder::Append to not use strcpyn and SIZE_UNKNOWN > > Also add explicit includes of rtc_base/string_utils.h in files depending on it. > > Bug: webrtc:6424 > Change-Id: Id6b53937ab2d185d092a5d8863018fd5f1a88e27 > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/135744 > Reviewed-by: Karl Wiberg <kwiberg@webrtc.org> > Commit-Queue: Niels Moller <nisse@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#27903} TBR=kwiberg@webrtc.org,nisse@webrtc.org Change-Id: Ib04280d401b66fe832d3fdc9293e39276710f973 No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: webrtc:6424 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/135945 Reviewed-by: Niels Moller <nisse@webrtc.org> Commit-Queue: Niels Moller <nisse@webrtc.org> Cr-Commit-Position: refs/heads/master@{#27909}
This commit is contained in:
parent
e1225d389e
commit
fb8c856afa
@ -36,7 +36,6 @@ enum PreservedErrno {
|
||||
#include "rtc_base/helpers.h"
|
||||
#include "rtc_base/logging.h"
|
||||
#include "rtc_base/numerics/safe_conversions.h"
|
||||
#include "rtc_base/string_utils.h"
|
||||
#include "rtc_base/thread_checker.h"
|
||||
#include "rtc_base/trace_event.h"
|
||||
#include "usrsctplib/usrsctp.h"
|
||||
|
||||
@ -26,7 +26,6 @@
|
||||
#include "modules/audio_device/audio_device_name.h"
|
||||
#include "modules/audio_device/include/audio_device_defines.h"
|
||||
#include "rtc_base/logging.h"
|
||||
#include "rtc_base/string_utils.h"
|
||||
|
||||
#pragma comment(lib, "Avrt.lib")
|
||||
|
||||
|
||||
@ -29,7 +29,6 @@
|
||||
#include "rtc_base/network.h"
|
||||
#include "rtc_base/numerics/safe_minmax.h"
|
||||
#include "rtc_base/string_encode.h"
|
||||
#include "rtc_base/string_utils.h"
|
||||
#include "rtc_base/third_party/base64/base64.h"
|
||||
#include "system_wrappers/include/field_trial.h"
|
||||
|
||||
|
||||
@ -45,7 +45,6 @@
|
||||
#include "rtc_base/checks.h"
|
||||
#include "rtc_base/logging.h"
|
||||
#include "rtc_base/message_digest.h"
|
||||
#include "rtc_base/string_utils.h"
|
||||
#include "rtc_base/strings/string_builder.h"
|
||||
#include "rtc_base/third_party/base64/base64.h"
|
||||
|
||||
|
||||
@ -30,7 +30,6 @@
|
||||
#include "rtc_base/logging.h"
|
||||
#include "rtc_base/message_digest.h"
|
||||
#include "rtc_base/socket_address.h"
|
||||
#include "rtc_base/string_utils.h"
|
||||
#include "rtc_base/strings/string_builder.h"
|
||||
#include "rtc_base/third_party/base64/base64.h" // for Base64
|
||||
#include "rtc_base/zero_memory.h" // for ExplicitZeroMemory
|
||||
|
||||
@ -25,7 +25,7 @@ SimpleStringBuilder::SimpleStringBuilder(rtc::ArrayView<char> buffer)
|
||||
}
|
||||
|
||||
SimpleStringBuilder& SimpleStringBuilder::operator<<(const char* str) {
|
||||
return Append(str, strlen(str));
|
||||
return Append(str);
|
||||
}
|
||||
|
||||
SimpleStringBuilder& SimpleStringBuilder::operator<<(char ch) {
|
||||
@ -106,12 +106,11 @@ SimpleStringBuilder& SimpleStringBuilder::AppendFormat(const char* fmt, ...) {
|
||||
|
||||
SimpleStringBuilder& SimpleStringBuilder::Append(const char* str,
|
||||
size_t length) {
|
||||
RTC_DCHECK_LT(size_ + length, buffer_.size())
|
||||
<< "Buffer size was insufficient";
|
||||
const size_t chars_added = rtc::SafeMin(length, buffer_.size() - size_ - 1);
|
||||
memcpy(&buffer_[size_], str, chars_added);
|
||||
const size_t chars_added =
|
||||
rtc::strcpyn(&buffer_[size_], buffer_.size() - size_, str, length);
|
||||
size_ += chars_added;
|
||||
buffer_[size_] = '\0';
|
||||
RTC_DCHECK_EQ(chars_added, length == SIZE_UNKNOWN ? std::strlen(str) : length)
|
||||
<< "Buffer size was insufficient";
|
||||
RTC_DCHECK(IsConsistent());
|
||||
return *this;
|
||||
}
|
||||
|
||||
@ -18,6 +18,7 @@
|
||||
#include "absl/strings/string_view.h"
|
||||
#include "api/array_view.h"
|
||||
#include "rtc_base/string_encode.h"
|
||||
#include "rtc_base/string_utils.h"
|
||||
|
||||
namespace rtc {
|
||||
|
||||
@ -63,7 +64,7 @@ class SimpleStringBuilder {
|
||||
|
||||
// An alternate way from operator<<() to append a string. This variant is
|
||||
// slightly more efficient when the length of the string to append, is known.
|
||||
SimpleStringBuilder& Append(const char* str, size_t length);
|
||||
SimpleStringBuilder& Append(const char* str, size_t length = SIZE_UNKNOWN);
|
||||
|
||||
private:
|
||||
bool IsConsistent() const {
|
||||
|
||||
@ -19,7 +19,6 @@
|
||||
#include "rtc_base/event.h"
|
||||
#include "rtc_base/logging.h"
|
||||
#include "rtc_base/platform_thread.h"
|
||||
#include "rtc_base/string_utils.h"
|
||||
#include "rtc_base/strings/string_builder.h"
|
||||
#include "rtc_base/system/inline.h"
|
||||
#include "system_wrappers/include/sleep.h"
|
||||
|
||||
@ -10,7 +10,6 @@
|
||||
#ifndef TEST_LOGGING_LOG_WRITER_H_
|
||||
#define TEST_LOGGING_LOG_WRITER_H_
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user