Am Mittwoch, 23. Mai 2007 schrieb Per Inge Mathisen: > On 5/23/07, Christian Ohm <[EMAIL PROTECTED]> wrote: > > Some g++ fixes again. > > Most of these are good, but do we need "fixes" of this kind?: > > - buffer = malloc(bufferSize + sizeof(soundDataBuffer)); > + buffer = (soundDataBuffer*) malloc(bufferSize + > sizeof(soundDataBuffer)); > > Please just use -fpermissive, or something, and don't clutter the code > with useless (and hard to maintain properly) casts like this. It is > not good C coding practice. Question: I've come along things like these before, too. The problem was that you need to match the sizeof() with the type of var you want to assign the memory to. I decided in that case, that it is good to explicitly cast, since then you will immediately notice that you forgot to change that assignment/allocation after changing the type of the var. So I found it to be useful for mallocs at least.
What do you think about this? Are there any problems with an explicit cast? Why should I not cast? --Dennis
signature.asc
Description: This is a digitally signed message part.
_______________________________________________ Warzone-dev mailing list Warzone-dev@gna.org https://mail.gna.org/listinfo/warzone-dev