[vlc-devel] [PATCH] demux/mp4: (asking for pre-review) add support of fMP4

Rémi Denis-Courmont remi at remlab.net
Thu Jan 26 17:03:59 CET 2012


Le jeudi 26 janvier 2012 16:32:19 Jean-Baptiste Kempf, vous avez écrit :
> > +MP4_Box_t *MP4_BoxGetNextChunk( stream_t *s, unsigned i_tk_id )
> > +{
> > +    /* p_chunk is a virtual root container for the moof and mdat boxes
> > */ +    MP4_Box_t *p_chunk;
> > +    MP4_Box_t *p_moof;
> > +    MP4_Box_t *p_mdat;
> > +
> > +    p_chunk = malloc( sizeof( MP4_Box_t ) );
> > +    p_mdat = malloc( sizeof( MP4_Box_t ) );
> > +    if( unlikely( p_chunk == NULL || p_mdat == NULL ) )
> > +        return NULL;
> > +
> > +    p_chunk->i_type = ATOM_root;
> > +    p_chunk->i_shortsize = 1;
> > +
> > +    p_chunk->data.p_data = NULL;
> > +    p_chunk->p_father    = NULL;
> > +    p_chunk->p_first     = NULL;
> > +    p_chunk->p_last      = NULL;
> > +    p_chunk->p_next      = NULL;
> 
> Why not calloc p_chunk ?

I don't like to calloc structures with pointers. This makes programmers 
sloppy. Besides, NULL is not warranted to be all zeroes in memory.

NetBSD even has a policy against this assumption.

-- 
Rémi Denis-Courmont
http://www.remlab.net/
http://fi.linkedin.com/in/remidenis



More information about the vlc-devel mailing list