X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=lib%2Fas3%2Fabc.c;h=b9509c4657414f95468e8e897853c40be75f96aa;hb=35d1f904be07a3edfd388dd563f1142609aa6d3c;hp=e07a0668b3a0d4b15a9eab705228bdb80d4da4f4;hpb=9fe415e64de83fab1753524196e557a9b13c4b1a;p=swftools.git diff --git a/lib/as3/abc.c b/lib/as3/abc.c index e07a066..b9509c4 100644 --- a/lib/as3/abc.c +++ b/lib/as3/abc.c @@ -345,7 +345,7 @@ static void dump_method(FILE*fo, const char*prefix, return_type = strdup("void"); fprintf(fo, "%s", prefix); - fprintf(fo, "%s %s", attr, type); + fprintf(fo, "%s %s ", attr, type); fprintf(fo, "%s %s=%s", return_type, name, m->name); params_dump(fo, m->parameters, m->optional_parameters); fprintf(fo, "(%d params, %d optional)\n", list_length(m->parameters), list_length(m->optional_parameters)); @@ -720,7 +720,6 @@ void* swf_ReadABC(TAG*tag) } pool_read(pool, tag); - //pool_dump(pool, stdout); int num_methods = swf_GetU30(tag); DEBUG printf("%d methods\n", num_methods); @@ -737,7 +736,7 @@ void* swf_ReadABC(TAG*tag) for(s=0;sparameters, param); } @@ -876,7 +875,7 @@ void* swf_ReadABC(TAG*tag) array_append(file->method_bodies, NO_KEY, c); } if(tag->len - tag->pos) { - fprintf(stderr, "%d unparsed bytes remaining in ABC block\n", tag->len - tag->pos); + fprintf(stderr, "ERROR: %d unparsed bytes remaining in ABC block\n", tag->len - tag->pos); return 0; } @@ -926,10 +925,11 @@ void* swf_ReadABC(TAG*tag) return file; } -void swf_WriteABC(TAG*abctag, void*code) +static pool_t*writeABC(TAG*abctag, void*code, pool_t*pool) { abc_file_t*file = (abc_file_t*)code; - pool_t*pool = pool_new(); + if(!pool) + pool = pool_new(); TAG*tmp = swf_InsertTag(0,0); TAG*tag = tmp; @@ -1188,11 +1188,22 @@ void swf_WriteABC(TAG*abctag, void*code) swf_SetBlock(tag, tmp->data, tmp->len); swf_DeleteTag(0, tmp); + return pool; +} + +void swf_WriteABC(TAG*abctag, void*code) +{ + pool_t*pool = writeABC(abctag, code, 0); + pool_optimize(pool); + swf_ResetTag(abctag, abctag->id); + writeABC(abctag, code, pool); pool_destroy(pool); } void abc_file_free(abc_file_t*file) { + if(!file) + return; int t; if(file->metadata) { for(t=0;tmetadata->num;t++) {