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

Side by Side Diff: net/base/dns_util.cc

Issue 266243004: Clang format slam. Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 months 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/base/dns_util.h" 5 #include "net/base/dns_util.h"
6 6
7 #include <cstring> 7 #include <cstring>
8 8
9 namespace net { 9 namespace net {
10 10
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 if (namelen + labellen + 1 > sizeof name) 43 if (namelen + labellen + 1 > sizeof name)
44 return false; 44 return false;
45 name[namelen++] = labellen; 45 name[namelen++] = labellen;
46 memcpy(name + namelen, label, labellen); 46 memcpy(name + namelen, label, labellen);
47 namelen += labellen; 47 namelen += labellen;
48 labellen = 0; 48 labellen = 0;
49 } 49 }
50 50
51 if (namelen + 1 > sizeof name) 51 if (namelen + 1 > sizeof name)
52 return false; 52 return false;
53 if (namelen == 0) // Empty names e.g. "", "." are not valid. 53 if (namelen == 0) // Empty names e.g. "", "." are not valid.
54 return false; 54 return false;
55 name[namelen++] = 0; // This is the root label (of length 0). 55 name[namelen++] = 0; // This is the root label (of length 0).
56 56
57 *out = std::string(name, namelen); 57 *out = std::string(name, namelen);
58 return true; 58 return true;
59 } 59 }
60 60
61 std::string DNSDomainToString(const base::StringPiece& domain) { 61 std::string DNSDomainToString(const base::StringPiece& domain) {
62 std::string ret; 62 std::string ret;
63 63
(...skipping 19 matching lines...) Expand all
83 std::string TrimEndingDot(const base::StringPiece& host) { 83 std::string TrimEndingDot(const base::StringPiece& host) {
84 base::StringPiece host_trimmed = host; 84 base::StringPiece host_trimmed = host;
85 size_t len = host_trimmed.length(); 85 size_t len = host_trimmed.length();
86 if (len > 1 && host_trimmed[len - 1] == '.') { 86 if (len > 1 && host_trimmed[len - 1] == '.') {
87 host_trimmed.remove_suffix(1); 87 host_trimmed.remove_suffix(1);
88 } 88 }
89 return host_trimmed.as_string(); 89 return host_trimmed.as_string();
90 } 90 }
91 91
92 } // namespace net 92 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698