From simon.urbanek at r-project.org  Tue Feb 21 21:16:08 2006
From: simon.urbanek at r-project.org (Simon Urbanek)
Date: Tue, 21 Feb 2006 15:16:08 -0500
Subject: [Rd] simple C function segfaults
In-Reply-To: <20060221194810.46878.qmail@web27414.mail.ukl.yahoo.com>
References: <20060221194810.46878.qmail@web27414.mail.ukl.yahoo.com>
Message-ID: <1AF14F32-B953-4D58-A02B-A5ED0F3FA8CA@r-project.org>


On Feb 21, 2006, at 2:48 PM, Bernd Kriegstein wrote:

> Thank you very much for the answer. As a general principle, when  
> and why should I register the counters?

"register int i" is merely an optimization, you can safely use "int  
i" instead. The "register" keyword only tells the compiler to store  
the variable in a CPU register where possible - it is not necessary  
at all (most modern compiler will optimize it correctly anyway).  
Crucial mistake in your example was the improper use of function  
parameters and pointers.

Cheers,
Simon



[Rd] simple C function segfaults
Simon Urbanek