[FFmpeg-devel] [PATCH] lavu/mem: extend documentation for av_dynarray_add()

Nicolas George nicolas.george at normalesup.org
Thu Apr 25 12:25:14 CEST 2013


Le sextidi 6 floréal, an CCXXI, Stefano Sabatini a écrit :
> ---
>  libavutil/mem.h |   14 +++++++++++---
>  1 file changed, 11 insertions(+), 3 deletions(-)
> 
> diff --git a/libavutil/mem.h b/libavutil/mem.h
> index ced9453..8ae0939 100644
> --- a/libavutil/mem.h
> +++ b/libavutil/mem.h
> @@ -191,9 +191,17 @@ void av_freep(void *ptr);
>  /**
>   * Add an element to a dynamic array.
>   *
> - * @param tab_ptr Pointer to the array.
> - * @param nb_ptr  Pointer to the number of elements in the array.
> - * @param elem    Element to be added.
> + * The array to add is supposed to be an array of pointers to
> + * structures, and the element to add must be a pointer to an already
> + * allocated structure.
> + *
> + * In case of success, the pointer to the array is updated in order to

> + * contain the new growed array, and the number pointed to by nb_ptr

growed -> grown

And possibly "to contain" -> "to point to".

> + * is incremented.

A note about efficiency would be nice:

 * The array is reallocated when its sizes reaches powers of 2.
 * Therefore, the amortized cost of adding an element is constant.

> + *
> + * @param tab_ptr pointer to the array to grow
> + * @param nb_ptr  pointer to the number of elements in the array
> + * @param elem    element to add
>   */
>  void av_dynarray_add(void *tab_ptr, int *nb_ptr, void *elem);

Regards,

-- 
  Nicolas George
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20130425/466cd390/attachment.asc>


More information about the ffmpeg-devel mailing list