X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=lib%2Fpython%2Ftag.c;h=65e19b35ec1419fa7afb61fc5a964d2621bf124f;hb=2206626c3b7fa0997a2472a28b78f3d42bfd2ae7;hp=a08e661ecf8deb1b0be6c884d8ec3bcc0968ab96;hpb=263d494bd93334ec04c81dcbe47b69675fa23007;p=swftools.git diff --git a/lib/python/tag.c b/lib/python/tag.c index a08e661..65e19b3 100644 --- a/lib/python/tag.c +++ b/lib/python/tag.c @@ -142,7 +142,7 @@ PyObject* tag_new() PyObject* tag_new2(TAG*t, PyObject* tagmap) { TagObject*tag = PyObject_New(TagObject, &TagClass); - mylog("+%08x(%d) tag_new tag=%08x\n", (int)tag, tag->ob_refcnt, t); + mylog("+%08x(%d) tag_new2 tag=%08x id=%d (%s)\n", (int)tag, tag->ob_refcnt, t, t->id, swf_TagGetName(t)); tag->font = 0; tag->character = 0; tag->placeobject = 0; @@ -153,19 +153,23 @@ PyObject* tag_new2(TAG*t, PyObject* tagmap) t = tag->tag; int num = swf_GetNumUsedIDs(t); - int * positions = malloc(num*sizeof(int)); - swf_GetUsedIDs(t, positions); - int i; - for(i=0;idata[positions[i]]); - PyObject*obj = tagmap_id2obj(tagmap, id); - if(obj==NULL) { - PyErr_SetString(PyExc_Exception, setError("TagID %d not defined", id)); - return NULL; + if(num) { // tag has dependencies + int * positions = malloc(num*sizeof(int)); + swf_GetUsedIDs(t, positions); + int i; + for(i=0;idata[positions[i]]); + PyObject*obj = tagmap_id2obj(tagmap, id); + if(obj==NULL) { + PyErr_SetString(PyExc_Exception, setError("TagID %d not defined", id)); + return NULL; + } + //mylog("+%08x(%d) tag_new2 handling id %d at %d/%d\n", (int)tag, tag->ob_refcnt, id, positions[i], t->len); + //mylog("+%08x(%d) tag_new2 add dependency %d to id %d, object %08x(%d)\n", (int)tag, tag->ob_refcnt, i, id, obj, obj->ob_refcnt); + tagmap_addMapping(tag->tagmap, id, obj); } - tagmap_addMapping(tag->tagmap, id, obj); + free(positions); } - free(positions); return (PyObject*)tag; } @@ -358,21 +362,23 @@ TAG* tag_getTAG(PyObject*self, TAG*prevTag, PyObject*tagmap) } int num = swf_GetNumUsedIDs(t); - int * positions = malloc(num*sizeof(int)); - swf_GetUsedIDs(t, positions); - int i; - for(i=0;idata[positions[i]]); - PyObject* obj = tagmap_id2obj(tag->tagmap, id); - if(obj==NULL) { - PyErr_SetString(PyExc_Exception, setError("Internal error: id %d not known in taglist:")); - free(positions); - return 0; + if(num) { // tag has dependencies + int * positions = malloc(num*sizeof(int)); + swf_GetUsedIDs(t, positions); + int i; + for(i=0;idata[positions[i]]); + PyObject* obj = tagmap_id2obj(tag->tagmap, id); + if(obj==NULL) { + PyErr_SetString(PyExc_Exception, setError("Internal error: id %d not known in taglist:")); + free(positions); + return 0; + } + int newid = tagmap_obj2id(tagmap, obj); + PUT16(&t->data[positions[i]], newid); } - int newid = tagmap_obj2id(tagmap, obj); - PUT16(&t->data[positions[i]], newid); + free(positions); } - free(positions); return t; }