[tpop3d-discuss]code questions

Jeff Davis tpop3d at empires.org
Fri, 12 Mar 2004 04:57:49 -0800


First I'd like to say I think the code is very good overall and very
well commented. However, I'm kind of a newbie to actually working with
other people's code (I am competent with C in most ways, but just not
other peoples' C), and some things confused me.

Example code in netloop.c fork_child:
for (J = connections; J < connections + max_connections; ++J)
    if (*J && *J != c) {
        close((*J)->s);
        (*J)->s = -1;
        connection_delete(*J);
        *J = NULL;
    }

Is that different from the more obvious solution (at least the obvious
solution to me):
for(i = 0; i < max_connections; ++i) {
    if ( connections[i] && connections[i] != c) {
        close(connections[i]->s);
        connections[i]->s = -1;
        connection_delete(connections[i]);
        connections[i] = NULL;
    }	
}

It just kind of caught me off guard to see the pointer-arithmetic loop.
I'm not challenging anything, but I'm trying to get some insight because
I'm not very experienced with other peoples' code.

Some other minor things included the huge case statements and the short
variable names (although I figured out the short names quickly enough).
There are some global vars around that I'm not quite understanding yet,
but I think those are necessary for the multi-process system.

I suppose I'll figure out the rest as I go. It really is nice code
compared with some other software I've seen out there, and the comments
are very helpful. The quality of the code is partially what gave me the
confidence to put the pop server into production.

Thanks,
	Jeff