[flac-dev] sf bug 258 - don't calloc pointers

Ralph Giles giles at thaumas.net
Mon Aug 19 20:01:59 PDT 2013


Bug suggests using literal assignment to initialize pointers in
structures instead of calloc, to avoid pointer-representation assumptions.

https://sourceforge.net/p/flac/bugs/258/


Pointers should not be initialised by the function "calloc" if they are
a member of a bigger data structure. Would you like to deal with an
internal representation that is not all-bits-0?
http://c-faq.com/null/varieties.html

I recommend to assign a "0" to data elements like "buffer" in the
functions "FLAC__bitreader_new" and "FLAC__bitwriter_new" separately.
http://flac.cvs.sourceforge.net/flac/flac/src/libFLAC/bitreader.c?revision=1.6&view=markup
http://flac.cvs.sourceforge.net/flac/flac/src/libFLAC/bitwriter.c?revision=1.8&view=markup

Are assignments for the data element "words" in the functions
"FLAC__bitreader_init" and "FLAC__bitwriter_init" unnecassary in this
context?


More information about the flac-dev mailing list