bluetooth: Move stuff to pa_bluetooth_transport_put/unlink()

This should not have any effect on behaviour. The goal is to align
with the pattern that I think we should follow:

Object initialization:
 - put() is the place to create references from other objects to the
   newly created object. In this case, adding the transport to
   discovery->transports was moved from new() to put, and adding the
   transport to device->transports was moved from set_state() to
   put().

Object destruction:
 - unlink() undoes put() and removes all references from other objects
   to the object being unlinked. In this case setting the
   device->transports pointer to NULL was moved from set_state() to
   unlink(), and setting the discovery->transports pointer to NULL was
   moved from free() to unlink().
 - free() undoes new(), but also calls unlink() so that object owners
   don't need to remember to call unlink() before free().
This commit is contained in:
Tanu Kaskinen 2014-10-07 14:50:21 +03:00
parent 4d9437d78a
commit 0df4d56cf8
2 changed files with 10 additions and 12 deletions

View file

@ -281,9 +281,6 @@ static void hf_audio_agent_card_removed(pa_bluetooth_backend *backend, const cha
if (!card)
return;
if (card->transport)
pa_bluetooth_transport_unlink(card->transport);
hf_audio_card_free(card);
}