Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(852)

Unified Diff: webrtc/voice_engine/voe_base_impl.cc

Issue 1493663002: Removing some unnecessary string manipulation code from VoEBase::GetVersion(). (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: implicit Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webrtc/voice_engine/voe_base_impl.h ('k') | webrtc/voice_engine/voice_engine_impl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/voice_engine/voe_base_impl.cc
diff --git a/webrtc/voice_engine/voe_base_impl.cc b/webrtc/voice_engine/voe_base_impl.cc
index 60a649eefd5770443bf8cdde279dfbbee2655440..931b546fb992de446da6aa7e5501db4011d68cf8 100644
--- a/webrtc/voice_engine/voe_base_impl.cc
+++ b/webrtc/voice_engine/voe_base_impl.cc
@@ -583,68 +583,18 @@ int VoEBaseImpl::StopSend(int channel) {
int VoEBaseImpl::GetVersion(char version[1024]) {
static_assert(kVoiceEngineVersionMaxMessageSize == 1024, "");
-
if (version == nullptr) {
shared_->SetLastError(VE_INVALID_ARGUMENT, kTraceError);
- return (-1);
- }
-
- char versionBuf[kVoiceEngineVersionMaxMessageSize];
- char* versionPtr = versionBuf;
-
- int32_t len = 0;
- int32_t accLen = 0;
-
- len = AddVoEVersion(versionPtr);
- if (len == -1) {
return -1;
}
- versionPtr += len;
- accLen += len;
- assert(accLen < kVoiceEngineVersionMaxMessageSize);
-
-#ifdef WEBRTC_EXTERNAL_TRANSPORT
- len = AddExternalTransportBuild(versionPtr);
- if (len == -1) {
- return -1;
- }
- versionPtr += len;
- accLen += len;
- assert(accLen < kVoiceEngineVersionMaxMessageSize);
-#endif
-
- memcpy(version, versionBuf, accLen);
- version[accLen] = '\0';
-
- // to avoid the truncation in the trace, split the string into parts
- char partOfVersion[256];
- for (int partStart = 0; partStart < accLen;) {
- memset(partOfVersion, 0, sizeof(partOfVersion));
- int partEnd = partStart + 180;
- while (version[partEnd] != '\n' && version[partEnd] != '\0') {
- partEnd--;
- }
- if (partEnd < accLen) {
- memcpy(partOfVersion, &version[partStart], partEnd - partStart);
- } else {
- memcpy(partOfVersion, &version[partStart], accLen - partStart);
- }
- partStart = partEnd;
- }
+ std::string versionString = VoiceEngine::GetVersionString() + "\n";
kwiberg-webrtc 2015/12/02 10:24:59 You force the allocation and deallocation of a sec
the sun 2015/12/02 10:44:18 Done.
+ RTC_DCHECK_GT(kVoiceEngineVersionMaxMessageSize, versionString.size());
+ memcpy(version, versionString.c_str(), versionString.size());
+ version[versionString.size()] = '\0';
kwiberg-webrtc 2015/12/02 10:24:59 I think it's generally a good idea to prefer std::
the sun 2015/12/02 10:44:17 Done.
return 0;
}
-int32_t VoEBaseImpl::AddVoEVersion(char* str) const {
- return sprintf(str, "VoiceEngine 4.1.0\n");
-}
-
-#ifdef WEBRTC_EXTERNAL_TRANSPORT
-int32_t VoEBaseImpl::AddExternalTransportBuild(char* str) const {
- return sprintf(str, "External transport build\n");
-}
-#endif
-
int VoEBaseImpl::LastError() { return (shared_->statistics().LastError()); }
int32_t VoEBaseImpl::StartPlayout() {
« no previous file with comments | « webrtc/voice_engine/voe_base_impl.h ('k') | webrtc/voice_engine/voice_engine_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698