I would encourage anyone interested in becoming a better C/C++ coder to
have a look at Courier's source. There are some fantastic examples of
how to write clean and efficient code in an application that demands
stability and speed. Great job by Sam, and all the other code
contributors.
Remembering to free memory (m)alloc'd in a different function (2
functions deep):
>From config_islocal() in islocal.c:
if (!isinit)
{
char *filename;
dbobj_init(&db);
filename=config_search("hosteddomains.dat");
isinit=1;
dbobj_open(&db, filename, "R");
free(filename);
}
Close a file handle as soon as possible (not wait until end of function)
for a file that is read *a lot*:
cread1l() from cread1l.c
FILE *fp=fopen(filename, "r");
char buf[256];
char *p;
if (!fp) return (0);
fgets(buf, sizeof(buf), fp);
fclose(fp);
...do other stuff..
--
Matt Pavlovich <[EMAIL PROTECTED]>
Allegiance Telecom, Inc.
-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
courier-users mailing list
[EMAIL PROTECTED]
Unsubscribe: https://lists.sourceforge.net/lists/listinfo/courier-users