U8*data;
while(op)
{
- action->next = (ActionTAG*)malloc(sizeof(ActionTAG));
- memset(action->next, 0, sizeof(ActionTAG));
+ action->next = (ActionTAG*)rfx_calloc(sizeof(ActionTAG));
action->next->prev = action;
action->next->next = 0;
action->next->parent = tmp.next;
length = swf_GetU16(tag);
if(length) {
- data = malloc(length);
+ data = (U8*)rfx_alloc(length);
swf_GetBlock(tag, data, length);
} else {
data = 0;
while(action)
{
ActionTAG*tmp;
- if(action->data && action->data != action->tmp)
- free(action->data);
+ if(action->data && action->data != action->tmp) {
+ rfx_free(action->data);
+ action->data = 0;
+ }
+ action->len = 0;
tmp = action;
action=action->next;
- free(tmp);
+ rfx_free(tmp);
}
}
case 'f':
return 2;
case 'u':
- return strlen(data)+1;
+ return strlen((const char*)data)+1;
case 't':
- return strlen(data)+1;
+ return strlen((const char*)data)+1;
case 'l':
- return strlen(data)+1;
+ return strlen((const char*)data)+1;
case 'c':
- return strlen(data)+1;
+ return strlen((const char*)data)+1;
case 'C':
return 2;
case 's':
case 'p': {
U8 type = *data++;
if(type == 0) {
- return 1+strlen(data)+1; //string
+ return 1+strlen((const char*)data)+1; //string
} else if (type == 1) {
return 1+4; //float
} else if (type == 2) {
printf(" String:\"%s\"", data);
#ifdef MAX_LOOKUP
if (entry<MAX_LOOKUP)
- lookup[entry++] = strdup(data);
+ lookup[entry++] = strdup((const char*)data);
#endif
} break;
case 'C': {
- poollen = *(U16*)data;
+ poollen = data[0]+256*data[1];
entry = 0;
printf("(%d entries)", poollen);
} break;
num = (data[s++]); //num
num += (data[s++])*256;
for(t=0;t<num;t++) {
- printf("%s",data);
+ printf("%s",data+s); // 10/22/04 MD: added +s to
if(t<num-1)
printf(", ");
while(data[s++]); //param
printf(" bool:%s", *value?"true":"false");
} else if (type == 6) {
U8 a[8];
- int t;
memcpy(&a[4],value,4);
memcpy(a,&value[4],4);
#ifdef WORDS_BIGENDIAN
+ int t;
for(t=0;t<4;t++) {
U8 tmp = a[t];
a[t]=a[7-t];
}
#ifdef MAX_LOOKUP
- for (t=0;t<MAX_LOOKUP;t++) if (lookup[t]) free(lookup[t]);
+ for (t=0;t<MAX_LOOKUP;t++) if (lookup[t]) rfx_free(lookup[t]);
#endif
}
case 'u': {
if(type&TYPE_URL)
{
- replacelen = strlen(data);
+ replacelen = strlen((const char*)data);
replacepos = data;
- replacement = callback(data); // may be null
+ replacement = (U8*)callback((char*)data); // may be null
}
} break;
case 't': {
if(type&TYPE_TARGET)
{
- replacelen = strlen(data);
+ replacelen = strlen((const char*)data);
replacepos = data;
- replacement = callback(data); // may be null
+ replacement = (U8*)callback((char*)data); // may be null
}
} break;
case 'c': {
if(type&TYPE_STRING)
{
- replacelen = strlen(data);
+ replacelen = strlen((const char*)data);
replacepos = data;
- replacement = callback(data); // may be null
+ replacement = (U8*)callback((char*)data); // may be null
}
} break;
case 'C': {
- poollen = (*(U16*)data);
+ poollen = (data[0]+256*data[1]);
} break;
case 'o': {
} break;
case 'p': {
U8 datatype = *data;
- char*value = &data[1];
+ char*value = (char*)&data[1];
if(datatype == 0) { //string
if(type&TYPE_STRING)
{
replacelen = strlen(value);
- replacepos = value;
- replacement = callback(value); // may be null
+ replacepos = (U8*)value;
+ replacement = (U8*)callback(value); // may be null
}
} else if (datatype == 8) { //lookup
}
if(replacement)
{
- int newlen = strlen(replacement);
- char * newdata = malloc(atag->len - replacelen + newlen);
+ int newlen = strlen((const char *)replacement);
+ char * newdata = (char*)rfx_alloc(atag->len - replacelen + newlen);
int rpos = replacepos - atag->data;
memcpy(newdata, atag->data, rpos);
memcpy(&newdata[rpos], replacement, newlen);
memcpy(&newdata[rpos+newlen], &replacepos[replacelen],
&data[atag->len] - &replacepos[replacelen]);
- free(atag->data);
- atag->data = newdata;
+ rfx_free(atag->data);
+ atag->data = (U8*)newdata;
data = &atag->data[rpos+newlen+1];
}
}
/*static ActionTAG* swf_ActionStart()
{
ActionTAG*atag;
- atag = (ActionTAG*)malloc(sizeof(ActionTAG));
+ atag = (ActionTAG*)rfx_alloc(sizeof(ActionTAG));
atag->prev = 0;
atag->next = 0;
atag->parent = 0;
}
last->prev->next = 0;
- free(last);
+ rfx_free(last);
}*/
static ActionTAG*lastATAG(ActionTAG*atag)
ActionTAG* swf_AddActionTAG(ActionTAG*atag, U8 op, U8*data, U16 len)
{
ActionTAG*tmp;
- tmp = (ActionTAG*)malloc(sizeof(ActionTAG));
+ tmp = (ActionTAG*)rfx_alloc(sizeof(ActionTAG));
tmp->next = 0;
if(atag) {
tmp->prev = atag;
tmp->prev = 0;
tmp->parent = tmp;
}
- if(data || !len)
+ if(data || !len) {
tmp->data = data;
- else
+ } else {
tmp->data = tmp->tmp;
+ }
tmp->len = len;
tmp->op = op;
{
atag = swf_AddActionTAG(atag, ACTION_PUSH, 0, 3);
*(U8*)atag->tmp = 9; //lookup
- *(U8*)&atag->tmp[1] = index;
+ *(U8*)&atag->tmp[1] = (U8)index;
*(U8*)&atag->tmp[2] = index>>8;
return atag;
}
-ActionTAG* action_PushString(ActionTAG*atag, char*str)
+ActionTAG* action_PushString(ActionTAG*atag, const char*str)
{
int l = strlen(str);
- char*ptr = (char*)malloc(l+2);
+ char*ptr = (char*)rfx_alloc(l+2);
ptr[0] = 0; // string
strcpy(&ptr[1], str);
return swf_AddActionTAG(atag, ACTION_PUSH, (U8*)ptr, l+2);
}
ActionTAG* action_PushFloat(ActionTAG*atag, float f)
{
- char*ptr = (char*)malloc(5);
+ char*ptr = (char*)rfx_alloc(5);
U32 fd = *(U32*)&f;
ptr[0] = 1; //float
ptr[1] = fd;
}
ActionTAG* action_PushDouble(ActionTAG*atag, double d)
{
- char*ptr = (char*)malloc(9);
+ char*ptr = (char*)rfx_alloc(9);
U8*dd = (U8*)&d;
ptr[0] = 6; //double
#ifdef WORDS_BIGENDIAN
ActionTAG* action_PushInt(ActionTAG*atag, int i)
{
atag = swf_AddActionTAG(atag, ACTION_PUSH, 0, 5);
- *(U8*)atag->tmp = 7; //int
+ atag->tmp[0] = 7; //int
atag->tmp[1] = i;
atag->tmp[2] = i>>8;
atag->tmp[3] = i>>16;
char*ptr = strdup(label);
return swf_AddActionTAG(atag, ACTION_GOTOLABEL, (U8*)ptr, strlen(ptr));
}
-ActionTAG* action_GetUrl(ActionTAG*atag, char* url, char* label)
+ActionTAG* action_GetUrl(ActionTAG*atag, const char* url, char* label)
{
int l1= strlen(url);
int l2= strlen(label);
- char*ptr = malloc(l1+l2+2);
+ char*ptr = (char*)rfx_alloc(l1+l2+2);
strcpy(ptr, url);
strcpy(&ptr[l1+1], label);
- return swf_AddActionTAG(atag, ACTION_GETURL, ptr, l1+l2+2);
+ return swf_AddActionTAG(atag, ACTION_GETURL, (U8*)ptr, l1+l2+2);
}
//TODO:
ActionTAG* action_DefineFunction(ActionTAG*atag, U8*data, int len) {return atag;}
if(!ret || buffer==0 || len == 0)
return 0;
- swf_SetBlock(tag, buffer, len);
+ swf_SetBlock(tag, (U8*)buffer, len);
swf_SetU8(tag, 0);
- free(buffer);
+ rfx_free(buffer);
a = swf_ActionGet(tag);
swf_DeleteTag(tag);