Skip to content

Commit 5e332a5

Browse files
author
ldx
committed
Release matches after use.
Matches are allocated dynamically for the same type except the first instance. Free them via _Buffer when the python object is gced.
1 parent 2f1ed44 commit 5e332a5

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

iptc/ip4tc.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,8 @@ def __init__(self, rule, name=None, match=None, revision=None):
450450
self._revision = revision
451451
else:
452452
self._revision = self._module.revision
453+
if self._module.next is not None:
454+
self._store_buffer(module)
453455

454456
self._match_buf = (ct.c_ubyte * self.size)()
455457
if match:
@@ -472,6 +474,10 @@ def __eq__(self, match):
472474
def __ne__(self, match):
473475
return not self.__eq__(match)
474476

477+
def _store_buffer(self, module):
478+
self._buffer = _Buffer()
479+
self._buffer.buffer = ct.cast(module, ct.POINTER(ct.c_ubyte))
480+
475481
def _final_check(self):
476482
self._xt.final_check_match(self._module)
477483

0 commit comments

Comments
 (0)