From 1767e0274bf68a01cf8ce48905f1e59532013928 Mon Sep 17 00:00:00 2001 From: Benjamin Peterson Date: Wed, 14 Mar 2012 21:50:29 -0500 Subject: [PATCH] free AST's dict --- Parser/asdl_c.py | 8 +++++++- Python/Python-ast.c | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/Parser/asdl_c.py b/Parser/asdl_c.py index 0be6c7fe81..81a3d6af58 100755 --- a/Parser/asdl_c.py +++ b/Parser/asdl_c.py @@ -608,6 +608,12 @@ typedef struct { PyObject *dict; } AST_object; +static void +ast_dealloc(AST_object *self) +{ + Py_CLEAR(self->dict); +} + static int ast_type_init(PyObject *self, PyObject *args, PyObject *kw) { @@ -696,7 +702,7 @@ static PyTypeObject AST_type = { "_ast.AST", sizeof(AST_object), 0, - 0, /* tp_dealloc */ + (destructor)ast_dealloc, /* tp_dealloc */ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ diff --git a/Python/Python-ast.c b/Python/Python-ast.c index 1178d74d7f..d9e13e28b0 100644 --- a/Python/Python-ast.c +++ b/Python/Python-ast.c @@ -460,6 +460,12 @@ typedef struct { PyObject *dict; } AST_object; +static void +ast_dealloc(AST_object *self) +{ + Py_CLEAR(self->dict); +} + static int ast_type_init(PyObject *self, PyObject *args, PyObject *kw) { @@ -548,7 +554,7 @@ static PyTypeObject AST_type = { "_ast.AST", sizeof(AST_object), 0, - 0, /* tp_dealloc */ + (destructor)ast_dealloc, /* tp_dealloc */ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ -- 2.40.0