X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=lib%2Fpython%2Ftaglist.c;h=e16f84a0b96a48f042d64043c0968dca950cfd68;hb=b4d2af74c98317254799a2e1642dce508afc9345;hp=711817e168ffe6fac31d804d552299a111e19d59;hpb=1db6d1ee4107fcceab86d2d8fe16c05983e320f8;p=swftools.git diff --git a/lib/python/taglist.c b/lib/python/taglist.c index 711817e..e16f84a 100644 --- a/lib/python/taglist.c +++ b/lib/python/taglist.c @@ -33,7 +33,14 @@ PyObject * taglist_new2(TAG*tag) int nr=0; TAG*t = tag; - while(t) {nr++;t=t->next;} + TAG*last = t; + while(t) {nr++;last=t;t=t->next;} + + if(last && last->id==ST_END) { + swf_DeleteTag(last); + nr--; + } + taglist->taglist = PyList_New(nr); mylog("+%08x(%d) taglist_new2: %d items", (int)taglist, taglist->ob_refcnt, nr); @@ -42,9 +49,14 @@ PyObject * taglist_new2(TAG*tag) t = tag; while(t) { PyObject*newtag = tag_new2(t, taglist->tagmap); + if(newtag==NULL) { + // pass through exception + return NULL; + } PyList_SET_ITEM(taglist->taglist,nr,newtag);Py_INCREF(newtag); if(swf_isDefiningTag(t)) { - tagmap_add(taglist->tagmap, newtag); + int id = swf_GetDefineID(t); + tagmap_addMapping(taglist->tagmap, id, newtag); } nr++; t=t->next; @@ -153,7 +165,7 @@ static int taglist_length(PyObject * self) //---------------------------------------------------------------------------- static int taglist_contains(PyObject * self, PyObject * tag) { - mylog(" %08x(%d) taglist_contains %08x", (int)self, self->ob_refcnt, tag); + /* TODO: optimize! */ TagListObject*taglist = (TagListObject*)self; PyObject*list = taglist->taglist; int l = PyList_Size(list); @@ -161,11 +173,9 @@ static int taglist_contains(PyObject * self, PyObject * tag) for(t=0;tob_refcnt); return 1; } } - mylog(" %08x(%d) taglist_contains: no", (int)self, self->ob_refcnt); return 0; } //---------------------------------------------------------------------------- @@ -264,7 +274,7 @@ static PyObject * taglist_item(PyObject * self, int index) PyObject*tag; mylog(" %08x(%d) taglist_item(%d)", (int)self, self->ob_refcnt, index); tag = PyList_GetItem(taglist->taglist, index); - Py_INCREF(tag); //TODO-REF + Py_INCREF(tag); return tag; } static PySequenceMethods taglist_as_sequence =