[MPlayer-cvslog] r32923 - trunk/gui/skin/font.c
Reimar Döffinger
Reimar.Doeffinger at gmx.de
Thu Feb 17 18:05:51 CET 2011
On 17 Feb 2011, at 17:36, Ingo Brückl <ib at wupperonline.de> wrote:
> Clément Boesch wrote on Thu, 17 Feb 2011 17:18:56 +0100:
>
>>> + bmpFont init = {0};
>>> - if ( ( Fonts[id]=calloc( 1,sizeof( bmpFont ) ) ) == NULL ) return -1;
>>> + if ( ( Fonts[id]=malloc( sizeof( bmpFont ) ) ) == NULL ) return -1;
>>> + *Fonts[id] = init;
>
>> Sorry to nag you again but...
>
> You don't. I learn so much new by this.
>
>> why do you do that? It is imo much more confusing.
>
> It's in the article Diego referred me to. The structure contains a pointer
> and you can't initialize it using calloc().
>
> I was already feeling uncomfortable when I saw this calloc() the first time,
> because I knew that a NULL pointer may not always have the value of "zero".
> The article enlightened me.
That is strictly speaking correct, but it also applies to a lot of other stuff, at least all floating point values, and I think all signed types.
Trying to be "correct" here is just adding complexity that is completely pointless since none of the systems we know about or ever tested (and that's a huge amount) have a problem in it.
In addition doing it only here is even more pointless, since there's at least 100 other places where the issue would remain.
>
More information about the MPlayer-cvslog
mailing list