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

Side by Side Diff: net/dns/dns_config_service_win_unittest.cc

Issue 169193002: Convert scoped_ptr_malloc -> scoped_ptr, part 2. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased Created 6 years, 10 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
« no previous file with comments | « net/dns/dns_config_service_win.cc ('k') | net/proxy/dhcp_proxy_script_adapter_fetcher_win.cc » ('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) 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 "net/dns/dns_config_service_win.h" 5 #include "net/dns/dns_config_service_win.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/win/windows_version.h" 9 #include "base/win/windows_version.h"
10 #include "net/dns/dns_protocol.h" 10 #include "net/dns/dns_protocol.h"
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 } 51 }
52 52
53 struct AdapterInfo { 53 struct AdapterInfo {
54 IFTYPE if_type; 54 IFTYPE if_type;
55 IF_OPER_STATUS oper_status; 55 IF_OPER_STATUS oper_status;
56 const WCHAR* dns_suffix; 56 const WCHAR* dns_suffix;
57 std::string dns_server_addresses[4]; // Empty string indicates end. 57 std::string dns_server_addresses[4]; // Empty string indicates end.
58 int ports[4]; 58 int ports[4];
59 }; 59 };
60 60
61 scoped_ptr_malloc<IP_ADAPTER_ADDRESSES> CreateAdapterAddresses( 61 scoped_ptr<IP_ADAPTER_ADDRESSES, base::FreeDeleter> CreateAdapterAddresses(
62 const AdapterInfo* infos) { 62 const AdapterInfo* infos) {
63 size_t num_adapters = 0; 63 size_t num_adapters = 0;
64 size_t num_addresses = 0; 64 size_t num_addresses = 0;
65 for (size_t i = 0; infos[i].if_type; ++i) { 65 for (size_t i = 0; infos[i].if_type; ++i) {
66 ++num_adapters; 66 ++num_adapters;
67 for (size_t j = 0; !infos[i].dns_server_addresses[j].empty(); ++j) { 67 for (size_t j = 0; !infos[i].dns_server_addresses[j].empty(); ++j) {
68 ++num_addresses; 68 ++num_addresses;
69 } 69 }
70 } 70 }
71 71
72 size_t heap_size = num_adapters * sizeof(IP_ADAPTER_ADDRESSES) + 72 size_t heap_size = num_adapters * sizeof(IP_ADAPTER_ADDRESSES) +
73 num_addresses * (sizeof(IP_ADAPTER_DNS_SERVER_ADDRESS) + 73 num_addresses * (sizeof(IP_ADAPTER_DNS_SERVER_ADDRESS) +
74 sizeof(struct sockaddr_storage)); 74 sizeof(struct sockaddr_storage));
75 scoped_ptr_malloc<IP_ADAPTER_ADDRESSES> heap( 75 scoped_ptr<IP_ADAPTER_ADDRESSES, base::FreeDeleter> heap(
76 reinterpret_cast<IP_ADAPTER_ADDRESSES*>(malloc(heap_size))); 76 static_cast<IP_ADAPTER_ADDRESSES*>(malloc(heap_size)));
77 CHECK(heap.get()); 77 CHECK(heap.get());
78 memset(heap.get(), 0, heap_size); 78 memset(heap.get(), 0, heap_size);
79 79
80 IP_ADAPTER_ADDRESSES* adapters = heap.get(); 80 IP_ADAPTER_ADDRESSES* adapters = heap.get();
81 IP_ADAPTER_DNS_SERVER_ADDRESS* addresses = 81 IP_ADAPTER_DNS_SERVER_ADDRESS* addresses =
82 reinterpret_cast<IP_ADAPTER_DNS_SERVER_ADDRESS*>(adapters + num_adapters); 82 reinterpret_cast<IP_ADAPTER_DNS_SERVER_ADDRESS*>(adapters + num_adapters);
83 struct sockaddr_storage* storage = 83 struct sockaddr_storage* storage =
84 reinterpret_cast<struct sockaddr_storage*>(addresses + num_addresses); 84 reinterpret_cast<struct sockaddr_storage*>(addresses + num_addresses);
85 85
86 for (size_t i = 0; i < num_adapters; ++i) { 86 for (size_t i = 0; i < num_adapters; ++i) {
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after
458 EXPECT_EQ(t.unhandled_options, config.unhandled_options); 458 EXPECT_EQ(t.unhandled_options, config.unhandled_options);
459 EXPECT_EQ(t.have_nrpt, config.use_local_ipv6); 459 EXPECT_EQ(t.have_nrpt, config.use_local_ipv6);
460 } 460 }
461 } 461 }
462 462
463 463
464 } // namespace 464 } // namespace
465 465
466 } // namespace net 466 } // namespace net
467 467
OLDNEW
« no previous file with comments | « net/dns/dns_config_service_win.cc ('k') | net/proxy/dhcp_proxy_script_adapter_fetcher_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698