From 69025de84f10ba3a322f35a448c3618745c89ffa Mon Sep 17 00:00:00 2001 From: "matthias.ringwald" Date: Sun, 13 Jun 2010 21:27:47 +0000 Subject: [PATCH] streamline deletion code --- src/l2cap.c | 8 ++++---- src/sdp.c | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/l2cap.c b/src/l2cap.c index ac4b30dc8..1497f6abd 100644 --- a/src/l2cap.c +++ b/src/l2cap.c @@ -706,11 +706,11 @@ void l2cap_close_connection(connection_t *connection){ } // unregister services - l2cap_service_t *service; - for (it = (linked_item_t *) &l2cap_services; it->next; ){ - service = (l2cap_service_t *) it->next; + it = (linked_item_t *) &l2cap_services; + while (it->next){ + l2cap_service_t * service = (l2cap_service_t *) it->next; if (service->connection == connection){ - it->next = service->item.next; + it->next = it->next->next; free(service); } else { it = it->next; diff --git a/src/sdp.c b/src/sdp.c index 019eba203..8e5a0de44 100644 --- a/src/sdp.c +++ b/src/sdp.c @@ -184,10 +184,10 @@ void sdp_unregister_service_internal(connection_t *connection, uint32_t service_ void sdp_unregister_services_for_connection(connection_t *connection){ linked_item_t *it = (linked_item_t *) &sdp_service_records; while (it->next){ - if (((service_record_item_t *)(it->next))->connection == connection){ - linked_item_t *toDelete = it->next; + service_record_item_t *record_item = (service_record_item_t *) it->next; + if (record_item->connection == connection){ it->next = it->next->next; - free(toDelete); + free(record_item); } else { it = it->next; }