Re: [PATCH BlueZ 1/3] shared/queue: Simplify queue_remove_all

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

On Mon, Nov 17, 2014 at 4:40 PM, Luiz Augusto von Dentz
<luiz.dentz@xxxxxxxxx> wrote:
> From: Luiz Augusto von Dentz <luiz.von.dentz@xxxxxxxxx>
>
> This makes use of queue_remove_if if possible.
> ---
>  src/shared/queue.c | 22 +++++-----------------
>  1 file changed, 5 insertions(+), 17 deletions(-)
>
> diff --git a/src/shared/queue.c b/src/shared/queue.c
> index 3ca3ca6..6bfe995 100644
> --- a/src/shared/queue.c
> +++ b/src/shared/queue.c
> @@ -312,31 +312,19 @@ unsigned int queue_remove_all(struct queue *queue, queue_match_func_t function,
>         entry = queue->head;
>
>         if (function) {
> -               struct queue_entry *prev = NULL;
> -
>                 while (entry) {
> -                       if (function(entry->data, user_data)) {
> -                               struct queue_entry *tmp = entry;
> -
> -                               if (prev)
> -                                       prev->next = entry->next;
> -                               else
> -                                       queue->head = entry->next;
> -
> -                               if (!entry->next)
> -                                       queue->tail = prev;
> +                       void *data;
>
> +                       data = queue_remove_if(queue, function, user_data);
> +                       if (data) {
>                                 entry = entry->next;
>
>                                 if (destroy)
> -                                       destroy(tmp->data);
> +                                       destroy(data);
>
> -                               free(tmp);
>                                 count++;
> -                       } else {
> -                               prev = entry;
> +                       } else
>                                 entry = entry->next;
> -                       }
>                 }
>
>                 queue->entries -= count;
> --
> 1.9.3

Pushed.


-- 
Luiz Augusto von Dentz
--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux