has_references function for counting references for WEAK pointer