void CS_DelLabel (CodeSeg* S, CodeLabel* L) /* Remove references from this label and delete it. */ { unsigned Count, I; /* First, remove the label from the hash chain */ CS_RemoveLabelFromHash (S, L); /* Remove references from insns jumping to this label */ Count = CollCount (&L->JumpFrom); for (I = 0; I < Count; ++I) { /* Get the insn referencing this label */ CodeEntry* E = CollAt (&L->JumpFrom, I); /* Remove the reference */ CE_ClearJumpTo (E); } CollDeleteAll (&L->JumpFrom); /* Remove the reference to the owning instruction if it has one. The * function may be called for a label without an owner when deleting * unfinished parts of the code. This is unfortunate since it allows * errors to slip through. */ if (L->Owner) { CollDeleteItem (&L->Owner->Labels, L); } /* All references removed, delete the label itself */ FreeCodeLabel (L); }
void CE_MoveLabel (CodeLabel* L, CodeEntry* E) /* Move the code label L from it's former owner to the code entry E. */ { /* Delete the label from the owner */ CollDeleteItem (&L->Owner->Labels, L); /* Set the new owner */ CollAppend (&E->Labels, L); L->Owner = E; }
void CS_RemoveLabelRef (CodeSeg* S, struct CodeEntry* E) /* Remove the reference between E and the label it jumps to. The reference * will be removed on both sides and E->JumpTo will be 0 after that. If * the reference was the only one for the label, the label will get * deleted. */ { /* Get a pointer to the label and make sure it exists */ CodeLabel* L = E->JumpTo; CHECK (L != 0); /* Delete the entry from the label */ CollDeleteItem (&L->JumpFrom, E); /* The entry jumps no longer to L */ CE_ClearJumpTo (E); /* If there are no more references, delete the label */ if (CollCount (&L->JumpFrom) == 0) { CS_DelLabel (S, L); } }
void FreeObjData (ObjData* O) /* Free an ObjData object. NOTE: This function works only for unused object * data, that is, ObjData objects that aren't used because they aren't * referenced. */ { unsigned I; for (I = 0; I < CollCount (&O->Files); ++I) { CollDeleteItem (&((FileInfo*) CollAtUnchecked (&O->Files, I))->Modules, O); } DoneCollection (&O->Files); DoneCollection (&O->Sections); for (I = 0; I < CollCount (&O->Exports); ++I) { FreeExport (CollAtUnchecked (&O->Exports, I)); } DoneCollection (&O->Exports); for (I = 0; I < CollCount (&O->Imports); ++I) { FreeImport (CollAtUnchecked (&O->Imports, I)); } DoneCollection (&O->Imports); DoneCollection (&O->DbgSyms); DoneCollection (&O->HLLDbgSyms); for (I = 0; I < CollCount (&O->LineInfos); ++I) { FreeLineInfo (CollAtUnchecked (&O->LineInfos, I)); } DoneCollection (&O->LineInfos); xfree (O->Strings); DoneCollection (&O->Assertions); DoneCollection (&O->Scopes); for (I = 0; I < CollCount (&O->Spans); ++I) { FreeSpan (CollAtUnchecked (&O->Spans, I)); } DoneCollection (&O->Spans); xfree (O); }