Commits

Armin Rigo  committed c2e8c09

Don't track allocations that go straight into "setdata()", where they
will be handled by the __del__().

  • Participants
  • Parent commits 961fb06

Comments (0)

Files changed (1)

File rpython/rlib/rsocket.py

 
     def __del__(self):
         if self.addr_p:
-            lltype.free(self.addr_p, flavor='raw')
+            lltype.free(self.addr_p, flavor='raw', track_allocation=False)
 
     def setdata(self, addr, addrlen):
         # initialize self.addr and self.addrlen.  'addr' can be a different
         result = instantiate(INETAddress)
         # store the malloc'ed data into 'result' as soon as possible
         # to avoid leaks if an exception occurs inbetween
-        sin = lltype.malloc(_c.sockaddr_in, flavor='raw', zero=True)
+        sin = lltype.malloc(_c.sockaddr_in, flavor='raw', zero=True,
+                            track_allocation=False)
         result.setdata(sin, sizeof(_c.sockaddr_in))
         # PLAT sin_len
         rffi.setintfield(sin, 'c_sin_family', AF_INET)
         result = instantiate(INET6Address)
         # store the malloc'ed data into 'result' as soon as possible
         # to avoid leaks if an exception occurs inbetween
-        sin = lltype.malloc(_c.sockaddr_in6, flavor='raw', zero=True)
+        sin = lltype.malloc(_c.sockaddr_in6, flavor='raw', zero=True,
+                            track_allocation=False)
         result.setdata(sin, sizeof(_c.sockaddr_in6))
         rffi.setintfield(sin, 'c_sin6_family', AF_INET6)
         rffi.structcopy(sin.c_sin6_addr, in6_addr)
         maxlen = sizeof(struct)
 
         def __init__(self, path):
-            sun = lltype.malloc(_c.sockaddr_un, flavor='raw', zero=True)
+            sun = lltype.malloc(_c.sockaddr_un, flavor='raw', zero=True,
+                                track_allocation=False)
             baseofs = offsetof(_c.sockaddr_un, 'c_sun_path')
             self.setdata(sun, baseofs + len(path))
             rffi.setintfield(sun, 'c_sun_family', AF_UNIX)
         maxlen = minlen = sizeof(struct)
 
         def __init__(self, pid, groups):
-            addr = lltype.malloc(_c.sockaddr_nl, flavor='raw', zero=True)
+            addr = lltype.malloc(_c.sockaddr_nl, flavor='raw', zero=True,
+                                 track_allocation=False)
             self.setdata(addr, NETLINKAddress.maxlen)
             rffi.setintfield(addr, 'c_nl_family', AF_NETLINK)
             rffi.setintfield(addr, 'c_nl_pid', pid)
         raise RSocketError("address family mismatched")
     # copy into a new buffer the address that 'addrptr' points to
     addrlen = rffi.cast(lltype.Signed, addrlen)
-    buf = lltype.malloc(rffi.CCHARP.TO, addrlen, flavor='raw')
+    buf = lltype.malloc(rffi.CCHARP.TO, addrlen, flavor='raw',
+                        track_allocation=False)
     src = rffi.cast(rffi.CCHARP, addrptr)
     for i in range(addrlen):
         buf[i] = src[i]
         result = instantiate(INETAddress)
     elif result.family != AF_INET:
         raise RSocketError("address family mismatched")
-    sin = lltype.malloc(_c.sockaddr_in, flavor='raw', zero=True)
+    sin = lltype.malloc(_c.sockaddr_in, flavor='raw', zero=True,
+                        track_allocation=False)
     result.setdata(sin, sizeof(_c.sockaddr_in))
     rffi.setintfield(sin, 'c_sin_family', AF_INET)   # PLAT sin_len
     rffi.setintfield(sin.c_sin_addr, 'c_s_addr', s_addr)
 def make_null_address(family):
     klass = familyclass(family)
     result = instantiate(klass)
-    buf = lltype.malloc(rffi.CCHARP.TO, klass.maxlen, flavor='raw', zero=True)
+    buf = lltype.malloc(rffi.CCHARP.TO, klass.maxlen, flavor='raw', zero=True,
+                        track_allocation=False)
     # Initialize the family to the correct value.  Avoids surprizes on
     # Windows when calling a function that unexpectedly does not set
     # the output address (e.g. recvfrom() on a connected IPv4 socket).