The code doesn't deep copy as the caller uses these strings.  That said, this loop doesn't properly free unused Apns from the list, nor does it free the outer struct in the case where a match has been found.