Compatible with obsolete code[HostileRefManager]

I have an old code that needs to be compatible with the latest TC 335.The code is like this

############################################################

void AttackersValue::AddAttackersOf(Unit* unit, set<Unit*>& targets)
{
HostileRefManager& refManager = unit->getHostileRefManager();
HostileReference *ref = refManager.getFirst();
if (!ref)
return;

while( ref )
    {
        ThreatManager *threatManager = ref->GetSource();
        Unit *attacker = threatManager->GetOwner();
        Unit *victim = attacker->GetVictim();
        if (victim == unit)
            targets.insert(attacker);
        ref = ref->next();
    }
}

############################################################

If we want to rewrite the method implementation of the new TC, how should we modify it?Mainly part HostileRefManager and Unit *attacker …

sorry my bad english.I sincerely thank you for help me.