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

Side by Side Diff: src/common/chromeos/string.cc

Issue 460001: Clean up to move NewStringCopy from util to chromoes/string. (Closed)
Patch Set: Removed pw file, changed include format Created 11 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 unified diff | Download patch
« no previous file with comments | « src/common/chromeos/string.h ('k') | src/common/util.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium OS Authors. All rights reserved. 1 // Copyright (c) 2009 The Chromium OS 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 <chromeos/string.h> 5 #include <chromeos/string.h>
6 6
7 #include <cstring>
8
7 #include <pcrecpp.h> 9 #include <pcrecpp.h>
8
9 #include "base/logging.h" 10 #include "base/logging.h"
10 11
11 namespace chromeos { 12 namespace chromeos {
12 13
13 void SplitString(const std::string& str, std::vector<std::string>* parts) { 14 void SplitString(const std::string& str, std::vector<std::string>* parts) {
14 CHECK(parts); 15 CHECK(parts);
15 parts->clear(); 16 parts->clear();
16 static pcrecpp::RE re("\\s*(\\S+)"); 17 static pcrecpp::RE re("\\s*(\\S+)");
17 pcrecpp::StringPiece input(str); 18 pcrecpp::StringPiece input(str);
18 19
(...skipping 19 matching lines...) Expand all
38 if (delim_pos == std::string::npos) { 39 if (delim_pos == std::string::npos) {
39 delim_pos = str.size(); 40 delim_pos = str.size();
40 } 41 }
41 if (delim_pos > start) { 42 if (delim_pos > start) {
42 parts->push_back(str.substr(start, delim_pos - start)); 43 parts->push_back(str.substr(start, delim_pos - start));
43 } 44 }
44 start = delim_pos + delim.size(); 45 start = delim_pos + delim.size();
45 } 46 }
46 } 47 }
47 48
49 char* NewStringCopy(const char* x) {
50 char* result = static_cast<char*>(::operator new(std::strlen(x) + 1));
51 std::strcpy(result, x); // NOLINT
52 return result;
53 }
54
48 } // namespace chromeos 55 } // namespace chromeos
49 56
OLDNEW
« no previous file with comments | « src/common/chromeos/string.h ('k') | src/common/util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698