www.pudn.com > DTMS.rar > FREE.C
#include "mail.h"
/* Free up a mail structure, and all the malloc'ed buffers it
* may point to. Also close the file descriptors if still open. */
int
_mail_free(MAIL *mail)
{
if (mail->idxfd >= 0 && close(mail->idxfd) < 0)
err_dump("index close error");
if (mail->datfd >= 0 && close(mail->datfd) < 0)
err_dump("data close error");
mail->idxfd = mail->datfd = -1;
if (mail->idxbuf != NULL)
free(mail->idxbuf);
if (mail->datbuf != NULL)
free(mail->datbuf);
if (mail->name != NULL)
free(mail->name);
free(mail);
return(0);
}