On Monday 19 June 2006 21:21, Jerry Feldman wrote:
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.
Very true. I wasn't really looking at that, I was more concerned with the unseemly use of pointer indirection elsewhere. If I was to really rewrite it I would do a lot more