[Ffmpeg-cvslog] r5530 - in trunk/libavcodec: vc1.c vc1acdata.h vc1data.h

Måns Rullgård mru
Wed Jun 28 09:57:48 CEST 2006

Rich Felker <dalias at aerifal.cx> writes:

> On Tue, Jun 27, 2006 at 03:39:02PM +0200, Michael Niedermayer wrote:
>> > +static int alloc_bitplane(BitPlane *bp, int width, int height)
>> >  {
>> > +    if (!bp || bp->width<0 || bp->height<0) return -1;
>> > +    bp->data = (uint8_t*)av_malloc(width*height);
>> the cast is unneeded, IIRC rich once flamed someone due to such casts :)
> Yes it makes the code less readable and serves no purpose. Pointer
> casts are almost always either redundant (like here) or potentially
> hiding bugs by hiding serious warnings. If a pointer cast ever is
> necessary the correct destination type is almost always void *.

You never need to cast to void *.  As you say, pointer casts are
almost always hiding something.  It could be a real bug, or it could
be sloppy coding, but there's generally a better way to do it.  In few
rare cases it makes sense to cast one pointer type to another.

Much of the same is true for casts between non-pointer types, although
the situations where they are legitimate are different.

M?ns Rullg?rd
mru at inprovide.com

More information about the ffmpeg-cvslog mailing list