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

Side by Side Diff: runtime/bin/socket_win.cc

Issue 1781883002: Fixes some memory leaks in //runtime/bin (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Fix tests on Windows Created 4 years, 9 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 | « runtime/bin/socket_macos.cc ('k') | runtime/bin/utils_win.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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "platform/globals.h" 5 #include "platform/globals.h"
6 #if defined(TARGET_OS_WINDOWS) 6 #if defined(TARGET_OS_WINDOWS)
7 7
8 #include "bin/socket.h"
9 #include "bin/socket_win.h"
10
8 #include "bin/builtin.h" 11 #include "bin/builtin.h"
9 #include "bin/eventhandler.h" 12 #include "bin/eventhandler.h"
10 #include "bin/file.h" 13 #include "bin/file.h"
11 #include "bin/lockers.h" 14 #include "bin/lockers.h"
12 #include "bin/log.h" 15 #include "bin/log.h"
13 #include "bin/socket.h"
14 #include "bin/thread.h" 16 #include "bin/thread.h"
15 #include "bin/utils.h" 17 #include "bin/utils.h"
16 #include "bin/utils_win.h" 18 #include "bin/utils_win.h"
17 19
18
19 namespace dart { 20 namespace dart {
20 namespace bin { 21 namespace bin {
21 22
22 SocketAddress::SocketAddress(struct sockaddr* sockaddr) { 23 SocketAddress::SocketAddress(struct sockaddr* sockaddr) {
23 ASSERT(INET6_ADDRSTRLEN >= INET_ADDRSTRLEN); 24 ASSERT(INET6_ADDRSTRLEN >= INET_ADDRSTRLEN);
24 RawAddr* raw = reinterpret_cast<RawAddr*>(sockaddr); 25 RawAddr* raw = reinterpret_cast<RawAddr*>(sockaddr);
25 26
26 // Clear the port before calling WSAAddressToString as WSAAddressToString 27 // Clear the port before calling WSAAddressToString as WSAAddressToString
27 // includes the port in the formatted string. 28 // includes the port in the formatted string.
28 int err = Socket::FormatNumericAddress(*raw, as_string_, INET6_ADDRSTRLEN); 29 int err = Socket::FormatNumericAddress(*raw, as_string_, INET6_ADDRSTRLEN);
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 360
360 bool Socket::ParseAddress(int type, const char* address, RawAddr* addr) { 361 bool Socket::ParseAddress(int type, const char* address, RawAddr* addr) {
361 int result; 362 int result;
362 const wchar_t* system_address = StringUtilsWin::Utf8ToWide(address); 363 const wchar_t* system_address = StringUtilsWin::Utf8ToWide(address);
363 if (type == SocketAddress::TYPE_IPV4) { 364 if (type == SocketAddress::TYPE_IPV4) {
364 result = InetPton(AF_INET, system_address, &addr->in.sin_addr); 365 result = InetPton(AF_INET, system_address, &addr->in.sin_addr);
365 } else { 366 } else {
366 ASSERT(type == SocketAddress::TYPE_IPV6); 367 ASSERT(type == SocketAddress::TYPE_IPV6);
367 result = InetPton(AF_INET6, system_address, &addr->in6.sin6_addr); 368 result = InetPton(AF_INET6, system_address, &addr->in6.sin6_addr);
368 } 369 }
369 free(const_cast<wchar_t*>(system_address));
370 return result == 1; 370 return result == 1;
371 } 371 }
372 372
373 373
374 intptr_t Socket::CreateBindDatagram(const RawAddr& addr, bool reuseAddress) { 374 intptr_t Socket::CreateBindDatagram(const RawAddr& addr, bool reuseAddress) {
375 SOCKET s = socket(addr.ss.ss_family, SOCK_DGRAM, IPPROTO_UDP); 375 SOCKET s = socket(addr.ss.ss_family, SOCK_DGRAM, IPPROTO_UDP);
376 if (s == INVALID_SOCKET) { 376 if (s == INVALID_SOCKET) {
377 return -1; 377 return -1;
378 } 378 }
379 379
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after
708 proto, 708 proto,
709 MCAST_LEAVE_GROUP, 709 MCAST_LEAVE_GROUP,
710 reinterpret_cast<char *>(&mreq), 710 reinterpret_cast<char *>(&mreq),
711 sizeof(mreq)) == 0; 711 sizeof(mreq)) == 0;
712 } 712 }
713 713
714 } // namespace bin 714 } // namespace bin
715 } // namespace dart 715 } // namespace dart
716 716
717 #endif // defined(TARGET_OS_WINDOWS) 717 #endif // defined(TARGET_OS_WINDOWS)
OLDNEW
« no previous file with comments | « runtime/bin/socket_macos.cc ('k') | runtime/bin/utils_win.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698