>>>>> "SP" == Smelly Pooh <plop at redbrick.dcu.ie> writes:
SP> In reply to Dave Neary's flatulent wordings,
>> Dave Neary wrote:
>> > strcat((msg=strdup(strvar1),
>> > (msg=realloc(msg,strlen(msg)+strlen(strvar2)+1))==NULL?
>> > bad_stuff():msg),strvar2);
>> works :) I was only confusing myself with the whole "order of
>> evaluation" red herring, since the first arg doesn't go near the second
>> arg. But anyone who ever used this should be shot :)
SP> If order of evaluation was right to left however then you will
SP> be realloccing an unallocated msg, strlen() msg which could
SP> lead to a seg fault if msg doesn't point somewhere valid and
SP> generaly make things quite sucky
The comma operator is totally different to the comma that separates
arguments to a function. Expressions are sequenced by the comma
operator and are executed from left-to-right, in order. The strdup
will thus always evaluate before the realloc. Nevertheless, it is
bad, nasty code that does not buy you anything except, perhaps, job
///////////////// | | The spark of a pin
<sneakums at zork.net> | left blank. | dropping, falling feather-like.
\\\\\\\\\\\\\\\\\ | | There is too much noise.
Maintained by the ILUG website team. The aim of Linux.ie is to
support and help commercial and private users of Linux in Ireland. You can
display ILUG news in your own webpages, read backend
information to find out how. Networking services kindly provided by HEAnet, server kindly donated by
Dell. Linux is a trademark of Linus Torvalds,
used with permission. No penguins were harmed in the production or maintenance
of this highly praised website. Looking for the
Indian Linux Users' Group? Try here. If you've read all this and aren't a lawyer: you should be!