From: kramm Date: Thu, 8 Apr 2004 09:16:58 +0000 (+0000) Subject: fixed mem leak in taglist_new() X-Git-Tag: stable_core_1~2 X-Git-Url: http://git.asbjorn.it/?a=commitdiff_plain;h=174af29d0c3a94c14b56f1509845fdab5d6409d0;p=swftools.git fixed mem leak in taglist_new() --- diff --git a/lib/python/taglist.c b/lib/python/taglist.c index 7e101c8..182e8bb 100644 --- a/lib/python/taglist.c +++ b/lib/python/taglist.c @@ -15,6 +15,16 @@ typedef struct { PyObject* taglist; } TagListObject; //---------------------------------------------------------------------------- +static void taglist_showcontents(PyObject* self) +{ + TagListObject*taglist = (TagListObject*)self; + int t, l = PyList_Size(taglist->taglist); + for(t=0;ttaglist, t); + mylog(" %08x(%d) taglist_showcontents item=%08x(%d)\n", (int)self, self->ob_refcnt, item, item->ob_refcnt); + } +} +//---------------------------------------------------------------------------- PyObject * taglist_new() { TagListObject* taglist = PyObject_New(TagListObject, &TagListClass); @@ -58,6 +68,7 @@ PyObject * taglist_new2(TAG*tag) } nr++; t=t->next; + Py_DECREF(newtag); } Py_DECREF(tagmap); return (PyObject*)taglist; @@ -136,15 +147,6 @@ static PyObject * taglist_optimizeOrder(PyObject* self, PyObject* args) return PY_NONE; } //---------------------------------------------------------------------------- -static void taglist_dealloc(PyObject* self) -{ - TagListObject*taglist = (TagListObject*)self; - mylog("-%08x(%d) taglist_dealloc list=%08x(%d)\n", (int)self, self->ob_refcnt, taglist->taglist, taglist->taglist->ob_refcnt); - Py_DECREF(taglist->taglist); - taglist->taglist = 0; - PyObject_Del(self); -} -//---------------------------------------------------------------------------- static PyMethodDef taglist_functions[] = {{"foldAll", taglist_foldAll, METH_VARARGS, "fold all sprites (movieclips) in the list"}, {"unfoldAll", taglist_unfoldAll, METH_VARARGS, "unfold (expand) all sprites (movieclips) in the list"}, @@ -277,6 +279,17 @@ static PyObject * taglist_item(PyObject * self, int index) Py_INCREF(tag); return tag; } +//---------------------------------------------------------------------------- +static void taglist_dealloc(PyObject* self) +{ + TagListObject*taglist = (TagListObject*)self; + mylog("-%08x(%d) taglist_dealloc list=%08x(%d)\n", (int)self, self->ob_refcnt, taglist->taglist, taglist->taglist->ob_refcnt); + taglist_showcontents(self); + Py_DECREF(taglist->taglist); + taglist->taglist = 0; + PyObject_Del(self); +} +//---------------------------------------------------------------------------- static PySequenceMethods taglist_as_sequence = { sq_length: taglist_length, // len(obj)