Well, it doesn't run for very long. I tried adding a
into it, but then it aborted for some reason.Code:for(;;)
Well, it doesn't run for very long. I tried adding a
into it, but then it aborted for some reason.Code:for(;;)
Last edited by elliptic; 06-05-2006 at 07:52 PM.
Faq to the rescue: http://faq.cprogramming.com/cgi-bin/...&id=1043284385
[EDIT]
Though, I'd make it pause before the calls to free().
Last edited by bivhitscar; 06-05-2006 at 08:04 PM.
it's ironic considerate rarity patron of love higher knowledge engulfs me...
> I'm on Win2k, running cygwin.
Mine is limited to 2MB of stack space.Code:$ ulimit -a core file size (blocks, -c) unlimited data seg size (kbytes, -d) unlimited file size (blocks, -f) unlimited open files (-n) 256 pipe size (512 bytes, -p) 8 stack size (kbytes, -s) 2042 cpu time (seconds, -t) unlimited max user processes (-u) 63 virtual memory (kbytes, -v) 2097152
> Red = create(w*h*sizeof(uint32));
Add NULL checks as appropriate.Code:uint32 **create ( uint32 w, uint32 h ) { uint32 i; uint32 **result = malloc ( h * sizeof *result ); for ( i = 0 ; i < h ; i++ ) result[i] = malloc ( w * sizeof *result[i] ); return result; }
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.