<<< Date Index >>>     <<< Thread Index >>>

Re: Little code cleanup



Dear all,

In the context of an off-list discussion, a friend of mine wrote what
follows (Actually this was written in french and I am translating):

In my opinion, the problem comes from the fact that C does not make a
clear distinction between arrays and pointers which are, however, two
objects of very different natures. Here fname and mbox are arrays, not
pointers. This is precisely why one can write things like
"sizeof(mbox)". Since the abovementionned variables are arrays, it makes
not really sense to verify that their addresses are non-NULL. Or, one
should also verify for every variable (e.g. of type int) that its
address is non-NULL before assigning it a value. If the code evolves in
such a way that the variables in question become dynamic arrays, one
will NEVER have a really dynamic array in the function, only a POINTER
pointing to a dynamic array and it will be this pointer which could
perhaps be NULL. But changing the type of a variable from array to
pointer is never trivialexactly in the same waygoing from "int" to "int
*" is not, and will require several changes in the function anyway.

Hope the translation is faithful to the original version.

Regards,
Sébastien.