[FFmpeg-devel] [PATCH 3/3] avutil/tree: add additional const qualifier to the comparator

Henrik Gramner henrik at gramner.com
Sun Oct 25 01:17:13 CEST 2015


On Sun, Oct 25, 2015 at 12:02 AM, Ganesh Ajjanagadde
<gajjanagadde at gmail.com> wrote:
> -static int cmp(void *key, const void *node)
> +static int cmp(const void *key, const void *node)
>  {
>      return (*(int64_t *) key) - ((const CacheEntry *) node)->logical_pos;
>  }

> -int ff_nut_sp_pos_cmp(const Syncpoint *a, const Syncpoint *b)
> +int ff_nut_sp_pos_cmp(const void *a, const void *b)
>  {
> -    return ((a->pos - b->pos) >> 32) - ((b->pos - a->pos) >> 32);
> +    Syncpoint va = *(Syncpoint *)a, vb = *(Syncpoint *)b;
> +    return ((va.pos - vb.pos) >> 32) - ((vb.pos - va.pos) >> 32);
>  }

> -int ff_nut_sp_pts_cmp(const Syncpoint *a, const Syncpoint *b)
> +int ff_nut_sp_pts_cmp(const void *a, const void *b)
>  {
> -    return ((a->ts - b->ts) >> 32) - ((b->ts - a->ts) >> 32);
> +    Syncpoint va = *(Syncpoint *)a, vb = *(Syncpoint *)b;
> +    return ((va.ts - vb.ts) >> 32) - ((vb.ts - va.ts) >> 32);
>  }

Casts discards const qualifiers.

Furthermore, why are you changing the two last functions to copy the
entire struct to a temporary local copy?


More information about the ffmpeg-devel mailing list