void lo_DestroyScriptData(void *arg) { ScriptData *data = arg; if (data == NULL) return; XP_FREEIF(data->url); XP_FREEIF(data->archiveSrc); XP_FREEIF(data->id); XP_FREEIF(data->codebase); XP_FREEIF(data->buffer); if (data->tag) PA_FreeTag(data->tag); XP_FREE(data); }
lo_ObjectStack* lo_PushObject(MWContext* context, lo_DocState* state, PA_Tag* tag) { /* * If possible, reuse an object stack entry created in * a previous pass over this tag (i.e. while blocked, by * lo_BlockObjectTag). If there's no previously-created * object, make a new one. */ lo_TopState* top_state = state->top_state; lo_ObjectStack* new_top = top_state->object_cache; if (new_top != NULL) { /* Find and remove the matching item, if any */ if (new_top->real_tag == tag) top_state->object_cache = new_top->next; else { while (new_top->next != NULL) { if (new_top->next->real_tag == tag) { lo_ObjectStack* temp = new_top->next; new_top->next = new_top->next->next; new_top = temp; break; } new_top = new_top->next; } } } if (new_top == NULL || new_top->real_tag != tag) { new_top = XP_NEW_ZAP(lo_ObjectStack); if (new_top == NULL) { state->top_state->out_of_memory = TRUE; return NULL; } } new_top->next = top_state->object_stack; top_state->object_stack = new_top; new_top->context = context; new_top->state = state; /* * Clone the tag since the tag passed in may be freed * by the parser before we're ready for it. */ if (new_top->real_tag != tag) { new_top->real_tag = tag; if (new_top->clone_tag != NULL) PA_FreeTag(new_top->clone_tag); new_top->clone_tag = XP_NEW(PA_Tag); if (new_top->clone_tag != NULL) { XP_MEMCPY(new_top->clone_tag, tag, sizeof(PA_Tag)); new_top->clone_tag->data = PA_ALLOC((tag->data_len + 1) * sizeof (char)); if (new_top->clone_tag->data != NULL) { char* source; char* dest; PA_LOCK(source, char*, tag->data); PA_LOCK(dest, char*, new_top->clone_tag->data); XP_MEMCPY(dest, source, tag->data_len + 1); PA_UNLOCK(dest); PA_UNLOCK(source); }