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

Side by Side Diff: content/common/url_schemes.cc

Issue 649533003: C++11 declares a type safe null pointer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed Presubmit errors Created 6 years, 2 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
« no previous file with comments | « content/common/shareable_file_reference_unittest.cc ('k') | no next file » | 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "content/common/url_schemes.h" 5 #include "content/common/url_schemes.h"
6 6
7 #include <string.h> 7 #include <string.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <string> 10 #include <string>
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 // prevent accidental creation of data races in the program. AddStandardScheme 45 // prevent accidental creation of data races in the program. AddStandardScheme
46 // isn't threadsafe so must be called when GURL isn't used on any other 46 // isn't threadsafe so must be called when GURL isn't used on any other
47 // thread. This is really easy to mess up, so we say that all calls to 47 // thread. This is really easy to mess up, so we say that all calls to
48 // AddStandardScheme in Chrome must be inside this function. 48 // AddStandardScheme in Chrome must be inside this function.
49 if (lock_standard_schemes) 49 if (lock_standard_schemes)
50 url::LockStandardSchemes(); 50 url::LockStandardSchemes();
51 51
52 // We rely on the above lock to protect this part from being invoked twice. 52 // We rely on the above lock to protect this part from being invoked twice.
53 if (!additional_savable_schemes.empty()) { 53 if (!additional_savable_schemes.empty()) {
54 const char* const* default_schemes = GetSavableSchemesInternal(); 54 const char* const* default_schemes = GetSavableSchemesInternal();
55 const char* const* default_schemes_end = NULL; 55 const char* const* default_schemes_end = nullptr;
56 for (default_schemes_end = default_schemes; *default_schemes_end; 56 for (default_schemes_end = default_schemes; *default_schemes_end;
57 ++default_schemes_end) {} 57 ++default_schemes_end) {}
58 const int default_schemes_count = default_schemes_end - default_schemes; 58 const int default_schemes_count = default_schemes_end - default_schemes;
59 59
60 int schemes = static_cast<int>(additional_savable_schemes.size()); 60 int schemes = static_cast<int>(additional_savable_schemes.size());
61 // The array, and the copied schemes won't be freed, but will remain 61 // The array, and the copied schemes won't be freed, but will remain
62 // reachable. 62 // reachable.
63 char **savable_schemes = new char*[schemes + default_schemes_count + 1]; 63 char **savable_schemes = new char*[schemes + default_schemes_count + 1];
64 memcpy(savable_schemes, 64 memcpy(savable_schemes,
65 default_schemes, 65 default_schemes,
66 default_schemes_count * sizeof(default_schemes[0])); 66 default_schemes_count * sizeof(default_schemes[0]));
67 for (int i = 0; i < schemes; ++i) { 67 for (int i = 0; i < schemes; ++i) {
68 savable_schemes[default_schemes_count + i] = 68 savable_schemes[default_schemes_count + i] =
69 base::strdup(additional_savable_schemes[i].c_str()); 69 base::strdup(additional_savable_schemes[i].c_str());
70 } 70 }
71 savable_schemes[default_schemes_count + schemes] = 0; 71 savable_schemes[default_schemes_count + schemes] = 0;
72 72
73 SetSavableSchemes(savable_schemes); 73 SetSavableSchemes(savable_schemes);
74 } 74 }
75 } 75 }
76 76
77 } // namespace content 77 } // namespace content
OLDNEW
« no previous file with comments | « content/common/shareable_file_reference_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698