X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=lib%2Fmodules%2Fswfaction.c;h=051de9b7ca22fd3ad968928297172aa2992b21a0;hb=80cc20b7784cccc9d8baf9839f9781db6bb6f539;hp=eb876d66b4941382b1a02c664008c96c68067cd8;hpb=07945d325222915907e9ef6a953e1c800424c0f0;p=swftools.git diff --git a/lib/modules/swfaction.c b/lib/modules/swfaction.c index eb876d6..051de9b 100644 --- a/lib/modules/swfaction.c +++ b/lib/modules/swfaction.c @@ -154,8 +154,7 @@ ActionTAG* swf_ActionGet(TAG*tag) 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; @@ -168,7 +167,7 @@ ActionTAG* swf_ActionGet(TAG*tag) length = swf_GetU16(tag); if(length) { - data = malloc(length); + data = rfx_alloc(length); swf_GetBlock(tag, data, length); } else { data = 0; @@ -195,12 +194,15 @@ void swf_ActionFree(ActionTAG*action) 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); } } @@ -354,7 +356,7 @@ void swf_DumpActions(ActionTAG*atag, char*prefix) #endif } break; case 'C': { - poollen = *(U16*)data; + poollen = data[0]+256*data[1]; entry = 0; printf("(%d entries)", poollen); } break; @@ -375,7 +377,7 @@ void swf_DumpActions(ActionTAG*atag, char*prefix) num = (data[s++]); //num num += (data[s++])*256; for(t=0;tlen - replacelen + newlen); + char * newdata = 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); + rfx_free(atag->data); atag->data = newdata; data = &atag->data[rpos+newlen+1]; } @@ -637,7 +639,7 @@ void swf_ActionEnumerateURLs(ActionTAG*atag, char*(*callback)(char*)) /*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; @@ -655,7 +657,7 @@ void swf_ActionEnd(ActionTAG* atag) } last->prev->next = 0; - free(last); + rfx_free(last); }*/ static ActionTAG*lastATAG(ActionTAG*atag) @@ -671,7 +673,7 @@ 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; @@ -681,10 +683,11 @@ ActionTAG* swf_AddActionTAG(ActionTAG*atag, U8 op, U8*data, U16 len) 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; @@ -1012,17 +1015,17 @@ ActionTAG* action_PushLookup16(ActionTAG*atag, U16 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; @@ -1033,7 +1036,7 @@ ActionTAG* action_PushFloat(ActionTAG*atag, float f) } 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 @@ -1052,7 +1055,7 @@ ActionTAG* action_PushDouble(ActionTAG*atag, double d) 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; @@ -1068,7 +1071,7 @@ ActionTAG* action_GetUrl(ActionTAG*atag, char* url, char* label) { int l1= strlen(url); int l2= strlen(label); - char*ptr = malloc(l1+l2+2); + char*ptr = rfx_alloc(l1+l2+2); strcpy(ptr, url); strcpy(&ptr[l1+1], label); return swf_AddActionTAG(atag, ACTION_GETURL, ptr, l1+l2+2); @@ -1096,7 +1099,7 @@ ActionTAG* swf_ActionCompile(const char* source, int version) swf_SetBlock(tag, buffer, len); swf_SetU8(tag, 0); - free(buffer); + rfx_free(buffer); a = swf_ActionGet(tag); swf_DeleteTag(tag);