summary refs log tree commit diff stats
path: root/lib/pure/net.nim
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2017-01-30 08:50:51 +0100
committerAndreas Rumpf <rumpf_a@web.de>2017-01-30 08:50:57 +0100
commit76eb20d2d3533588fcce6aa3e121f63d0ef87eea (patch)
treebe75da3c913f916952a2c86167a8cb06fdf9eb2b /lib/pure/net.nim
parent9f6f78ac6136a2d793fd20ca81e8cfaa8d1e1f28 (diff)
downloadNim-76eb20d2d3533588fcce6aa3e121f63d0ef87eea.tar.gz
deprecated nativesockets.dealloc, use freeAddrInfo instead; fixed stdlib deprecations
Diffstat (limited to 'lib/pure/net.nim')
-rw-r--r--lib/pure/net.nim24
1 files changed, 12 insertions, 12 deletions
diff --git a/lib/pure/net.nim b/lib/pure/net.nim
index 5e10f2291..7f6783358 100644
--- a/lib/pure/net.nim
+++ b/lib/pure/net.nim
@@ -204,12 +204,12 @@ proc newSocket*(fd: SocketHandle, domain: Domain = AF_INET,
     protocol: Protocol = IPPROTO_TCP, buffered = true): Socket =
   ## Creates a new socket as specified by the params.
   assert fd != osInvalidSocket
-  new(result)
-  result.fd = fd
-  result.isBuffered = buffered
-  result.domain = domain
-  result.sockType = sockType
-  result.protocol = protocol
+  result = Socket(
+    fd: fd,
+    isBuffered: buffered,
+    domain: domain,
+    sockType: sockType,
+    protocol: protocol)
   if buffered:
     result.currPos = 0
 
@@ -425,7 +425,7 @@ when defineSsl:
     ## **Disclaimer**: This code is not well tested, may be very unsafe and
     ## prone to security vulnerabilities.
 
-    assert (not socket.isSSL)
+    assert(not socket.isSSL)
     socket.isSSL = true
     socket.sslContext = ctx
     socket.sslHandle = SSLNew(socket.sslContext.context)
@@ -549,9 +549,9 @@ proc bindAddr*(socket: Socket, port = Port(0), address = "") {.
   else:
     var aiList = getAddrInfo(address, port, socket.domain)
     if bindAddr(socket.fd, aiList.ai_addr, aiList.ai_addrlen.SockLen) < 0'i32:
-      dealloc(aiList)
+      freeAddrInfo(aiList)
       raiseOSError(osLastError())
-    dealloc(aiList)
+    freeAddrInfo(aiList)
 
 proc acceptAddr*(server: Socket, client: var Socket, address: var string,
                  flags = {SocketFlag.SafeDisconn}) {.
@@ -1182,7 +1182,7 @@ proc sendTo*(socket: Socket, address: string, port: Port, data: pointer,
       break
     it = it.ai_next
 
-  dealloc(aiList)
+  freeAddrInfo(aiList)
 
 proc sendTo*(socket: Socket, address: string, port: Port,
              data: string): int {.tags: [WriteIOEffect].} =
@@ -1503,7 +1503,7 @@ proc connect*(socket: Socket, address: string,
     else: lastError = osLastError()
     it = it.ai_next
 
-  dealloc(aiList)
+  freeAddrInfo(aiList)
   if not success: raiseOSError(lastError)
 
   when defineSsl:
@@ -1551,7 +1551,7 @@ proc connectAsync(socket: Socket, name: string, port = Port(0),
 
     it = it.ai_next
 
-  dealloc(aiList)
+  freeAddrInfo(aiList)
   if not success: raiseOSError(lastError)
 
 proc connect*(socket: Socket, address: string, port = Port(0),