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

Ganesh Ajjanagadde gajjanag at mit.edu
Sun Oct 25 02:03:03 CET 2015


On Sat, Oct 24, 2015 at 7:17 PM, Henrik Gramner <henrik at gramner.com> wrote:
> 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.

Good catch, changed. There is some more such constness being discarded
in comparators, and some needlessly complex comparator logic in some
places. Submitted a patch.

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

Sorry, forgot they were structs.
Fixed all, pushed. Thanks.

> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


More information about the ffmpeg-devel mailing list