Remove std:: prefixes from C functions in talk/.

std::memcpy -> memcpy for instance. This change was motivated by a
compile report complaining that std::rand() was used instead of rand(),
probably with a stdlib.h include instead of cstdlib. Use of C functions
without the std:: prefix is a lot more common, so removing std:: to
address this.

BUG=
R=tommi@webrtc.org

Review URL: https://webrtc-codereview.appspot.com/9559004

git-svn-id: http://webrtc.googlecode.com/svn/trunk@5657 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
pbos@webrtc.org
2014-03-07 15:22:04 +00:00
parent 46509c8d58
commit 371243dfa3
58 changed files with 162 additions and 154 deletions

View File

@@ -27,7 +27,7 @@
#include "talk/base/asynctcpsocket.h"
#include <cstring>
#include <string.h>
#include "talk/base/byteorder.h"
#include "talk/base/common.h"

View File

@@ -28,7 +28,7 @@
#ifndef TALK_BASE_BUFFER_H_
#define TALK_BASE_BUFFER_H_
#include <cstring>
#include <string.h>
#include "talk/base/scoped_ptr.h"

View File

@@ -27,9 +27,10 @@
#include "talk/base/bytebuffer.h"
#include <assert.h>
#include <string.h>
#include <algorithm>
#include <cassert>
#include <cstring>
#include "talk/base/basictypes.h"
#include "talk/base/byteorder.h"

View File

@@ -28,9 +28,11 @@
#ifndef _TALK_BASE_CRYPTSTRING_H_
#define _TALK_BASE_CRYPTSTRING_H_
#include <cstring>
#include <string.h>
#include <string>
#include <vector>
#include "talk/base/linked_ptr.h"
#include "talk/base/scoped_ptr.h"

View File

@@ -68,9 +68,10 @@ class FakeSSLCertificate : public talk_base::SSLCertificate {
*algorithm = digest_algorithm_;
return true;
}
virtual bool ComputeDigest(const std::string &algorithm,
unsigned char *digest, std::size_t size,
std::size_t *length) const {
virtual bool ComputeDigest(const std::string& algorithm,
unsigned char* digest,
size_t size,
size_t* length) const {
*length = talk_base::ComputeDigest(algorithm, data_.c_str(), data_.size(),
digest, size);
return (*length != 0);

View File

@@ -25,7 +25,7 @@
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <cassert>
#include <assert.h>
#ifdef WIN32
// TODO(grunell): Remove io.h includes when Chromium has started

View File

@@ -27,7 +27,8 @@
#include "talk/base/firewallsocketserver.h"
#include <cassert>
#include <assert.h>
#include <algorithm>
#include "talk/base/asyncsocket.h"

View File

@@ -28,9 +28,9 @@
#include "talk/base/json.h"
#include <errno.h>
#include <limits.h>
#include <stdlib.h>
#include <climits>
#include <cstdlib>
#include <sstream>
bool GetStringFromJson(const Json::Value& in, std::string* out) {

View File

@@ -28,8 +28,9 @@
#ifndef TALK_BASE_MESSAGEQUEUE_H_
#define TALK_BASE_MESSAGEQUEUE_H_
#include <string.h>
#include <algorithm>
#include <cstring>
#include <list>
#include <queue>
#include <vector>

View File

@@ -155,7 +155,7 @@ void NATServer::OnExternalPacket(
remote_addr);
// Copy the data part after the address.
talk_base::PacketOptions options;
std::memcpy(real_buf.get() + addrlength, buf, size);
memcpy(real_buf.get() + addrlength, buf, size);
server_socket_->SendTo(real_buf.get(), size + addrlength,
iter->second->route.source(), options);
}

View File

@@ -47,12 +47,12 @@ size_t PackAddressForNAT(char* buf, size_t buf_size,
if (family == AF_INET) {
ASSERT(buf_size >= kNATEncodedIPv4AddressSize);
in_addr v4addr = ip.ipv4_address();
std::memcpy(&buf[4], &v4addr, kNATEncodedIPv4AddressSize - 4);
memcpy(&buf[4], &v4addr, kNATEncodedIPv4AddressSize - 4);
return kNATEncodedIPv4AddressSize;
} else if (family == AF_INET6) {
ASSERT(buf_size >= kNATEncodedIPv6AddressSize);
in6_addr v6addr = ip.ipv6_address();
std::memcpy(&buf[4], &v6addr, kNATEncodedIPv6AddressSize - 4);
memcpy(&buf[4], &v6addr, kNATEncodedIPv6AddressSize - 4);
return kNATEncodedIPv6AddressSize;
}
return 0U;
@@ -159,7 +159,7 @@ class NATSocket : public AsyncSocket, public sigslot::has_slots<> {
size + kNATEncodedIPv6AddressSize,
addr);
size_t encoded_size = size + addrlength;
std::memcpy(buf.get() + addrlength, data, size);
memcpy(buf.get() + addrlength, data, size);
int result = socket_->SendTo(buf.get(), encoded_size, server_addr_);
if (result >= 0) {
ASSERT(result == static_cast<int>(encoded_size));
@@ -196,7 +196,7 @@ class NATSocket : public AsyncSocket, public sigslot::has_slots<> {
SocketAddress real_remote_addr;
size_t addrlength =
UnpackAddressFromNAT(buf_, result, &real_remote_addr);
std::memcpy(data, buf_ + addrlength, result - addrlength);
memcpy(data, buf_ + addrlength, result - addrlength);
// Make sure this packet should be delivered before returning it.
if (!connected_ || (real_remote_addr == remote_addr_)) {

View File

@@ -25,7 +25,7 @@
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <cassert>
#include <assert.h>
#include "talk/base/nattypes.h"

View File

@@ -30,7 +30,7 @@
#ifdef POSIX
#include <netdb.h>
#include <cstddef>
#include <stddef.h>
#elif WIN32
#include <winsock2.h> // NOLINT
#endif

View File

@@ -60,8 +60,9 @@
#include <Iphlpapi.h>
#endif
#include <stdio.h>
#include <algorithm>
#include <cstdio>
#include "talk/base/logging.h"
#include "talk/base/scoped_ptr.h"

View File

@@ -211,8 +211,8 @@ bool NSSCertificate::IsValidChain(const CERTCertList* cert_list) {
return true;
}
bool NSSCertificate::GetDigestLength(const std::string &algorithm,
std::size_t *length) {
bool NSSCertificate::GetDigestLength(const std::string& algorithm,
size_t* length) {
const SECHashObject *ho;
if (!GetDigestObject(algorithm, &ho))
@@ -271,9 +271,10 @@ bool NSSCertificate::GetSignatureDigestAlgorithm(std::string* algorithm) const {
return true;
}
bool NSSCertificate::ComputeDigest(const std::string &algorithm,
unsigned char *digest, std::size_t size,
std::size_t *length) const {
bool NSSCertificate::ComputeDigest(const std::string& algorithm,
unsigned char* digest,
size_t size,
size_t* length) const {
const SECHashObject *ho;
if (!GetDigestObject(algorithm, &ho))

View File

@@ -84,8 +84,9 @@ class NSSCertificate : public SSLCertificate {
virtual bool GetSignatureDigestAlgorithm(std::string* algorithm) const;
virtual bool ComputeDigest(const std::string& algorithm,
unsigned char* digest, std::size_t size,
std::size_t* length) const;
unsigned char* digest,
size_t size,
size_t* length) const;
virtual bool GetChain(SSLCertChain** chain) const;
@@ -97,8 +98,7 @@ class NSSCertificate : public SSLCertificate {
static bool IsValidChain(const CERTCertList* cert_list);
// Helper function to get the length of a digest
static bool GetDigestLength(const std::string& algorithm,
std::size_t* length);
static bool GetDigestLength(const std::string& algorithm, size_t* length);
// Comparison. Only the certificate itself is considered, not the chain.
bool Equals(const NSSCertificate* tocompare) const;

View File

@@ -825,7 +825,7 @@ SECStatus NSSStreamAdapter::AuthCertificateHook(void *arg,
LOG(LS_INFO) << "Checking against specified digest";
// The peer certificate digest was specified
unsigned char digest[64]; // Maximum size
std::size_t digest_length;
size_t digest_length;
if (!peer_cert.ComputeDigest(
stream->peer_certificate_digest_algorithm_,

View File

@@ -103,8 +103,7 @@ class NSSStreamAdapter : public SSLStreamAdapterHelper {
// Override SSLStreamAdapterHelper
virtual int BeginSSL();
virtual void Cleanup();
virtual bool GetDigestLength(const std::string &algorithm,
std::size_t *length) {
virtual bool GetDigestLength(const std::string& algorithm, size_t* length) {
return NSSCertificate::GetDigestLength(algorithm, length);
}

View File

@@ -235,18 +235,18 @@ bool OpenSSLCertificate::GetSignatureDigestAlgorithm(
EVP_get_digestbyobj(x509_->sig_alg->algorithm), algorithm);
}
bool OpenSSLCertificate::ComputeDigest(const std::string &algorithm,
unsigned char *digest,
std::size_t size,
std::size_t *length) const {
bool OpenSSLCertificate::ComputeDigest(const std::string& algorithm,
unsigned char* digest,
size_t size,
size_t* length) const {
return ComputeDigest(x509_, algorithm, digest, size, length);
}
bool OpenSSLCertificate::ComputeDigest(const X509 *x509,
const std::string &algorithm,
unsigned char *digest,
std::size_t size,
std::size_t *length) {
bool OpenSSLCertificate::ComputeDigest(const X509* x509,
const std::string& algorithm,
unsigned char* digest,
size_t size,
size_t* length) {
const EVP_MD *md;
unsigned int n;

View File

@@ -94,16 +94,17 @@ class OpenSSLCertificate : public SSLCertificate {
virtual void ToDER(Buffer* der_buffer) const;
// Compute the digest of the certificate given algorithm
virtual bool ComputeDigest(const std::string &algorithm,
unsigned char *digest, std::size_t size,
std::size_t *length) const;
virtual bool ComputeDigest(const std::string& algorithm,
unsigned char* digest,
size_t size,
size_t* length) const;
// Compute the digest of a certificate as an X509 *
static bool ComputeDigest(const X509 *x509,
const std::string &algorithm,
unsigned char *digest,
std::size_t size,
std::size_t *length);
static bool ComputeDigest(const X509* x509,
const std::string& algorithm,
unsigned char* digest,
size_t size,
size_t* length);
virtual bool GetSignatureDigestAlgorithm(std::string* algorithm) const;

View File

@@ -780,7 +780,7 @@ int OpenSSLStreamAdapter::SSLVerifyCallback(int ok, X509_STORE_CTX* store) {
}
X509* cert = X509_STORE_CTX_get_current_cert(store);
unsigned char digest[EVP_MAX_MD_SIZE];
std::size_t digest_length;
size_t digest_length;
if (!OpenSSLCertificate::ComputeDigest(
cert,
stream->peer_certificate_digest_algorithm_,

View File

@@ -29,7 +29,7 @@
#pragma warning(disable:4786)
#endif
#include <cassert>
#include <assert.h>
#ifdef POSIX
#include <string.h>

View File

@@ -28,7 +28,7 @@
#ifndef TALK_APP_BASE_REFCOUNT_H_
#define TALK_APP_BASE_REFCOUNT_H_
#include <cstring>
#include <string.h>
#include "talk/base/criticalsection.h"

View File

@@ -88,8 +88,8 @@
#ifndef TALK_BASE_SCOPED_PTR_H__
#define TALK_BASE_SCOPED_PTR_H__
#include <cstddef> // for std::ptrdiff_t
#include <stdlib.h> // for free() decl
#include <stddef.h> // for ptrdiff_t
#include <stdlib.h> // for free() decl
#include <algorithm> // For std::swap().

View File

@@ -81,9 +81,10 @@ class SSLCertificate {
virtual bool GetSignatureDigestAlgorithm(std::string* algorithm) const = 0;
// Compute the digest of the certificate given algorithm
virtual bool ComputeDigest(const std::string &algorithm,
unsigned char* digest, std::size_t size,
std::size_t* length) const = 0;
virtual bool ComputeDigest(const std::string& algorithm,
unsigned char* digest,
size_t size,
size_t* length) const = 0;
};
// SSLCertChain is a simple wrapper for a vector of SSLCertificates. It serves

View File

@@ -87,8 +87,8 @@ class SSLStreamAdapterHelper : public SSLStreamAdapter {
// Must be implemented by descendents
virtual int BeginSSL() = 0;
virtual void Cleanup() = 0;
virtual bool GetDigestLength(const std::string &algorithm,
std::size_t *length) = 0;
virtual bool GetDigestLength(const std::string& algorithm,
size_t* length) = 0;
enum SSLState {
// Before calling one of the StartSSL methods, data flows

View File

@@ -27,8 +27,8 @@
#include "talk/base/stringencode.h"
#include <cstdio>
#include <cstdlib>
#include <stdio.h>
#include <stdlib.h>
#include "talk/base/basictypes.h"
#include "talk/base/common.h"

View File

@@ -31,6 +31,7 @@
#include <ctype.h>
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
#ifdef WIN32
#include <malloc.h>
@@ -46,7 +47,6 @@
#endif // !BSD
#endif // POSIX
#include <cstring>
#include <string>
#include "talk/base/basictypes.h"

View File

@@ -5,7 +5,7 @@
#ifndef TALK_BASE_TEMPLATE_UTIL_H_
#define TALK_BASE_TEMPLATE_UTIL_H_
#include <cstddef> // For size_t.
#include <stddef.h> // For size_t.
namespace talk_base {

View File

@@ -107,7 +107,7 @@ bool TestClient::CheckNextPacket(const char* buf, size_t size,
bool res = false;
Packet* packet = NextPacket();
if (packet) {
res = (packet->size == size && std::memcmp(packet->buf, buf, size) == 0);
res = (packet->size == size && memcmp(packet->buf, buf, size) == 0);
if (addr)
*addr = packet->addr;
delete packet;

View File

@@ -27,7 +27,7 @@
#include "talk/base/transformadapter.h"
#include <cstring>
#include <string.h>
#include "talk/base/common.h"

View File

@@ -27,7 +27,7 @@
#include "talk/base/versionparsing.h"
#include <cstdlib>
#include <stdlib.h>
namespace talk_base {

View File

@@ -25,11 +25,11 @@
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <math.h>
#include <time.h>
#ifdef POSIX
#include <netinet/in.h>
#endif
#include <cmath>
#include "talk/base/logging.h"
#include "talk/base/gunit.h"
@@ -686,7 +686,7 @@ class VirtualSocketServerTest : public testing::Test {
double num =
receiver.samples * receiver.sum_sq - receiver.sum * receiver.sum;
double den = receiver.samples * (receiver.samples - 1);
const double sample_stddev = std::sqrt(num / den);
const double sample_stddev = sqrt(num / den);
LOG(LS_VERBOSE) << "mean=" << sample_mean << " stddev=" << sample_stddev;
EXPECT_LE(500u, receiver.samples);
@@ -1002,7 +1002,7 @@ TEST_F(VirtualSocketServerTest, CreatesStandardDistribution) {
double dev = (*f)[i].second - mean;
sum_sq_dev += dev * dev;
}
const double stddev = std::sqrt(sum_sq_dev / f->size());
const double stddev = sqrt(sum_sq_dev / f->size());
EXPECT_NEAR(kTestMean[midx], mean, 0.1 * kTestMean[midx])
<< "M=" << kTestMean[midx]
<< " SD=" << kStdDev

View File

@@ -28,9 +28,9 @@
#include "talk/base/virtualsocketserver.h"
#include <errno.h>
#include <math.h>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
@@ -80,7 +80,7 @@ class Packet : public MessageData {
: size_(size), consumed_(0), from_(from) {
ASSERT(NULL != data);
data_ = new char[size_];
std::memcpy(data_, data, size_);
memcpy(data_, data, size_);
}
virtual ~Packet() {
@@ -283,7 +283,7 @@ class VirtualSocket : public AsyncSocket, public MessageHandler {
// Return the packet at the front of the queue.
Packet* packet = recv_buffer_.front();
size_t data_read = _min(cb, packet->size());
std::memcpy(pv, packet->data(), data_read);
memcpy(pv, packet->data(), data_read);
*paddr = packet->from();
if (data_read < packet->size()) {
@@ -963,11 +963,11 @@ void VirtualSocketServer::UpdateDelayDistribution() {
}
}
static double PI = 4 * std::atan(1.0);
static double PI = 4 * atan(1.0);
static double Normal(double x, double mean, double stddev) {
double a = (x - mean) * (x - mean) / (2 * stddev * stddev);
return std::exp(-a) / (stddev * sqrt(2 * PI));
return exp(-a) / (stddev * sqrt(2 * PI));
}
#if 0 // static unused gives a warning

View File

@@ -28,7 +28,8 @@
#ifndef TALK_BASE_VIRTUALSOCKETSERVER_H_
#define TALK_BASE_VIRTUALSOCKETSERVER_H_
#include <cassert>
#include <assert.h>
#include <deque>
#include <map>

View File

@@ -27,8 +27,8 @@
#include "talk/base/winping.h"
#include <assert.h>
#include <Iphlpapi.h>
#include <cassert>
#include "talk/base/byteorder.h"
#include "talk/base/common.h"