On Sun, 2004-12-12 at 05:07, Bill Kendrick wrote:
> On Fri, Dec 10, 2004 at 07:33:12AM -0500, Albert Cahalan wrote:
> > It's not crashing here. Type of crash?
> > (SIGKILL, SIGFPE, SIGSEGV, SIGBUS...)
> 
> Sigsegv.  I think my gcc didn't like "while (i--)" or something?
> (or maybe there was a double free()... i wasn't debugging it very
> professionally ;^) )
> 
> anyway, seems fixed and works fine now!

What compiler do you use? I hope it's 3.3 at least.
Random code tweaks are unreliable and unsafe.

BTW, some of the stuff you found odd:

Declaring variables right before use is less error-prone.
If you declare them at the top of the function and then
share them, the compiler is less able to correctly warn
about uninitialized variables. (the variables might be
initialized for one use, but not for later uses)

Considering these:
  work = malloc(sizeof *work * width * height);
  work = malloc(sizeof(multichan) * width * height);

In general, the "sizeof *work" one is safer. If the data
type is ever changed, the "sizeof(multichan)" one breaks.

I didn't check free() because:

1. Linux generally won't return an error anyway; the kernel
   will send SIGKILL if it can not provide the memory.
   (this is configurable, to satisfy financial institutions)

2. There is no reasonable way to handle the error.
   Calling exit() is really just a crash.


_______________________________________________
Tuxpaint-dev mailing list
[EMAIL PROTECTED]
http://tux4kids.net/mailman/listinfo/tuxpaint-dev

Reply via email to