X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=lib%2Fas3%2Fpool.c;h=4f37956c13d1a7440f1d6d4fd3b3f9cb404fc731;hb=41309f0ddb30036d2c07261dba583815e2f6068f;hp=0db750aacc6de1977d894f9f0eed170c9f0a6ca5;hpb=45c6d086e48f71cfb4c38a35d4cb6c26e15a9b21;p=swftools.git diff --git a/lib/as3/pool.c b/lib/as3/pool.c index 0db750a..4f37956 100644 --- a/lib/as3/pool.c +++ b/lib/as3/pool.c @@ -611,6 +611,7 @@ void multiname_destroy(multiname_t*m) if(m->namespace_set) { namespace_set_destroy(m->namespace_set);m->namespace_set = 0; } + m->type=0; free(m); } } @@ -720,7 +721,7 @@ char* constant_tostring(constant_t*c) { if(!c) return 0; - char buf[30]; + char buf[32]; if(NS_TYPE(c->type)) { return namespace_tostring(c->ns); } else if(c->type == CONSTANT_INT) { @@ -730,6 +731,7 @@ char* constant_tostring(constant_t*c) sprintf(buf, "%u", c->u); return strdup(buf); } else if(c->type == CONSTANT_FLOAT) { + char buf[1024]; sprintf(buf, "%f", c->f); return strdup(buf); } else if(c->type == CONSTANT_STRING) { @@ -813,7 +815,8 @@ int pool_register_float(pool_t*p, double d) int pool_register_string(pool_t*pool, const char*s) { if(!s) return 0; - int pos = array_append_if_new(pool->x_strings, s, 0); + ptroff_t l = strlen(s); + int pos = array_append_if_new(pool->x_strings, s, (void*)l); assert(pos!=0); return pos; } @@ -835,9 +838,6 @@ int pool_register_multiname(pool_t*pool, multiname_t*n) { if(!n) return 0; int pos = array_append_if_new(pool->x_multinames, n, 0); - if(pos==0) { - *(int*)0=0xdead; - } assert(pos!=0); return pos; } @@ -949,6 +949,12 @@ char*pool_lookup_string(pool_t*pool, int i) { return (char*)array_getkey(pool->x_strings, i); } +string_t pool_lookup_string2(pool_t*pool, int i) +{ + char*s = (char*)array_getkey(pool->x_strings, i); + int len = (int)(ptroff_t)array_getvalue(pool->x_strings, i); + return string_new(s,len); +} namespace_t*pool_lookup_namespace(pool_t*pool, int i) { return (namespace_t*)array_getkey(pool->x_namespaces, i); @@ -995,7 +1001,7 @@ void pool_read(pool_t*pool, TAG*tag) DEBUG printf("%d ints\n", num_ints); int t; for(t=1;tx_ints, &v, 0); } @@ -1003,7 +1009,7 @@ void pool_read(pool_t*pool, TAG*tag) int num_uints = swf_GetU30(tag); DEBUG printf("%d uints\n", num_uints); for(t=1;tx_uints, &v, 0); } @@ -1023,7 +1029,7 @@ void pool_read(pool_t*pool, TAG*tag) char*s = malloc(len+1); swf_GetBlock(tag, s, len); s[len] = 0; - array_append(pool->x_strings, s, 0); + array_append(pool->x_strings, s, (void*)(ptroff_t)len); free(s); DEBUG printf("%d) \"%s\"\n", t, pool->x_strings->d[t].name); } @@ -1126,7 +1132,7 @@ void pool_write(pool_t*pool, TAG*tag) However when actually using zero strings as empty namespaces, the flash player breaks.*/ //if(ns->name && ns->name[0]) - array_append_if_new(pool->x_strings, ns->name, 0); + pool_register_string(pool, ns->name); } //pool_register_int(pool, 15); @@ -1137,11 +1143,11 @@ void pool_write(pool_t*pool, TAG*tag) swf_SetU30(tag, pool->x_ints->num>1?pool->x_ints->num:0); for(t=1;tx_ints->num;t++) { S32 val = *(int*)array_getkey(pool->x_ints, t); - swf_SetS30(tag, val); + swf_SetABCS32(tag, val); } swf_SetU30(tag, pool->x_uints->num>1?pool->x_uints->num:0); for(t=1;tx_uints->num;t++) { - swf_SetU30(tag, *(unsigned int*)array_getkey(pool->x_uints, t)); + swf_SetABCU32(tag, *(unsigned int*)array_getkey(pool->x_uints, t)); } swf_SetU30(tag, pool->x_floats->num>1?pool->x_floats->num:0); for(t=1;tx_floats->num;t++) { @@ -1150,7 +1156,8 @@ void pool_write(pool_t*pool, TAG*tag) } swf_SetU30(tag, pool->x_strings->num>1?pool->x_strings->num:0); for(t=1;tx_strings->num;t++) { - swf_SetU30String(tag, array_getkey(pool->x_strings, t)); + string_t str = pool_lookup_string2(pool, t); + swf_SetU30String(tag, str.str, str.len); } swf_SetU30(tag, pool->x_namespaces->num>1?pool->x_namespaces->num:0); for(t=1;tx_namespaces->num;t++) {