612 |
} |
} |
613 |
} |
} |
614 |
|
|
615 |
void DestroyInstance(struct Instance *inst, struct Instance *parent) |
void DestroyInstance(struct Instance *inst, struct Instance *parent){ |
|
{ |
|
616 |
struct TypeDescription *desc; |
struct TypeDescription *desc; |
617 |
int delete; |
int delete; |
618 |
if (inst==NULL) return; |
if(inst==NULL) return; |
619 |
|
|
620 |
/*char *temp = WriteInstanceNameString(parent,NULL); |
if(InterfacePtrDelete!=NULL){ |
|
CONSOLE_DEBUG("parent name = %s",temp); |
|
|
ASC_FREE(temp);*/ |
|
|
|
|
|
if (InterfacePtrDelete!=NULL) { |
|
621 |
DeleteIPtr(inst); |
DeleteIPtr(inst); |
622 |
} |
} |
623 |
delete = RemoveParentReferences(inst,parent); |
delete = RemoveParentReferences(inst,parent); |
624 |
if (delete) { |
if(delete){ |
625 |
if (inst->t != DUMMY_INST) { |
if (inst->t != DUMMY_INST){ |
626 |
desc = InstanceTypeDesc(inst); |
desc = InstanceTypeDesc(inst); |
627 |
if (GetUniversalFlag(desc)){ /* universal is being deleted */ |
if(GetUniversalFlag(desc)){ /* universal is being deleted */ |
628 |
RemoveUniversalInstance(GetUniversalTable(),inst); |
RemoveUniversalInstance(GetUniversalTable(),inst); |
629 |
} |
} |
630 |
if (IsCompoundInstance(inst) && |
if(IsCompoundInstance(inst) && |
631 |
InstanceKind(inst) != SIM_INST && |
InstanceKind(inst) != SIM_INST && |
632 |
((struct PendInstance *)(inst))->p != NULL |
((struct PendInstance *)(inst))->p != NULL |
633 |
) { |
){ |
634 |
RemoveInstance(inst); |
RemoveInstance(inst); |
635 |
} |
} |
636 |
/* remove PENDING or maybe not pending instance in destroy process. */ |
/* remove PENDING or maybe not pending instance in destroy process. */ |
637 |
RemoveFromClique(inst); |
RemoveFromClique(inst); |
638 |
DestroyInstanceParts(inst); |
DestroyInstanceParts(inst); |
639 |
} else { |
}else{ |
640 |
if (D_INST(inst)->ref_count<2) { |
if(D_INST(inst)->ref_count<2){ |
641 |
desc = InstanceTypeDesc(inst); |
desc = InstanceTypeDesc(inst); |
642 |
if (GetUniversalFlag(desc)){ /* universal is being deleted */ |
if(GetUniversalFlag(desc)){ /* universal is being deleted */ |
643 |
RemoveUniversalInstance(GetUniversalTable(),inst); |
RemoveUniversalInstance(GetUniversalTable(),inst); |
644 |
} |
} |
645 |
/* dummy is never in cliques or pending */ |
/* dummy is never in cliques or pending */ |