On Wed, 23 May 2007 17:12:02 -0400 Per Inge Mathisen <[EMAIL PROTECTED]> wrote: >On 5/23/07, Dennis Schridde <[EMAIL PROTECTED]> wrote: >> > Most of these are good, but do we need "fixes" of this kind?: >> > >> > - buffer = malloc(bufferSize + sizeof(soundDataBuffer)); >> > + buffer = (soundDataBuffer*) malloc(bufferSize + >sizeof(soundDataBuffer)); >... >> Question: >... >> Why should I not cast? > >Casting is bad because it makes changing types later obnoxiously >hard. >It also clutters the code badly. Actually, the best way to do it >is >like this: > > buffer = malloc(bufferSize + sizeof(*buffer)); > >This way you do not explicitly mention the type, and if you later >change it, it will not cause size or casting problems. > > - Per What is use of sizeof (*buffer) ? Padding?
-- Looking for insurance? Compare and save 50% today. Click here. http://tagline.hushmail.com/fc/CAaCXv1QT6sib8saUWFKgBKPBhAepxgj/ _______________________________________________ Warzone-dev mailing list Warzone-dev@gna.org https://mail.gna.org/listinfo/warzone-dev