[PATCH 6/5] dynarray: Add pa_dynarray_last()

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

 



the description of pa_dynarray_last() should be something like
"Returns a pointer to the last element or NULL if the array is empty."

> ---
> 
> In addition to forgetting to add a cover letter to this patch series,
> I also didn't include the first patch. Here's the missing patch.
> 
> 
>  src/pulsecore/dynarray.c | 9 +++++++++
>  src/pulsecore/dynarray.h | 3 +++
>  2 files changed, 12 insertions(+)
> 
> diff --git a/src/pulsecore/dynarray.c b/src/pulsecore/dynarray.c
> index b207eca..82db496 100644
> --- a/src/pulsecore/dynarray.c
> +++ b/src/pulsecore/dynarray.c
> @@ -79,6 +79,15 @@ void *pa_dynarray_get(pa_dynarray *array, unsigned i) {
>      return array->data[i];
>  }
>  
> +void *pa_dynarray_last(pa_dynarray *array) {
> +    pa_assert(array);
> +
> +    if (array->n_entries == 0)
> +        return NULL;
> +
> +    return array->data[array->n_entries - 1];
> +}
> +
>  void *pa_dynarray_steal_last(pa_dynarray *array) {
>      pa_assert(array);
>  
> diff --git a/src/pulsecore/dynarray.h b/src/pulsecore/dynarray.h
> index 04dd2d2..743ac09 100644
> --- a/src/pulsecore/dynarray.h
> +++ b/src/pulsecore/dynarray.h
> @@ -50,6 +50,9 @@ void pa_dynarray_free(pa_dynarray *array);
>  void pa_dynarray_append(pa_dynarray *array, void *p);
>  void *pa_dynarray_get(pa_dynarray *array, unsigned i);
>  
> +/* Returns NULL if the array is empty. */
> +void *pa_dynarray_last(pa_dynarray *array);
> +
>  /* Returns the removed item, or NULL if the array is empty. */
>  void *pa_dynarray_steal_last(pa_dynarray *array);
>  
> -- 
> 1.9.3
> 
> _______________________________________________
> pulseaudio-discuss mailing list
> pulseaudio-discuss at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss
> 

-- 

Peter Meerwald
+43-664-2444418 (mobile)


[Index of Archives]     [Linux Audio Users]     [AMD Graphics]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux