On Monday 19 June 2006 2:16 pm, Anders Johansson wrote:
OK, I was wrong, it works. The layers of double indirection threw me. I think it's a very poor way of programming, I don't like it at all
Here's how I would do it, which I think is much easier to read
IntStruct *is = (IntStruct *) calloc(1, sizeof(IntStruct)); /* line 36 */ is->i = i; is->next = NULL;
This is a segfault waiting to happen. What happens if calloc(3) returns NULL? Always test the return values of malloc(3) and derivatives for NULL, otherwise there will be a point where the program will blow up. I agree 100% with Anders in that programs should be easy to read. If you get into the habit of producing readable code, your code will also be easier to debug, especially in the future after you have put it down then picked it up again (speaking from experience with assembler code and C). -- Jerry Feldman <gaf@blu.org> Boston Linux and Unix user group http://www.blu.org PGP key id:C5061EA9 PGP Key fingerprint:053C 73EC 3AC1 5C44 3E14 9245 FB00 3ED5 C506 1EA9