summaryrefslogtreecommitdiffstats
path: root/lib/mail.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--lib/mail.c (renamed from libmisc/mail.c)14
1 files changed, 6 insertions, 8 deletions
diff --git a/libmisc/mail.c b/lib/mail.c
index 647f879..d14bdb1 100644
--- a/libmisc/mail.c
+++ b/lib/mail.c
@@ -15,7 +15,9 @@
#include <stdio.h>
#include <string.h>
+#include "alloc.h"
#include "getdef.h"
+#include "string/sprintf.h"
#ident "$Id$"
@@ -34,22 +36,18 @@ void mailcheck (void)
*/
mailbox = getenv ("MAILDIR");
if (NULL != mailbox) {
- char *newmail;
- size_t len = strlen (mailbox) + 5;
- int wlen;
+ char *newmail;
- newmail = xmalloc (len);
- wlen = snprintf (newmail, len, "%s/new", mailbox);
- assert (wlen == (int) len - 1);
+ xasprintf(&newmail, "%s/new", mailbox);
if (stat (newmail, &statbuf) != -1 && statbuf.st_size != 0) {
if (statbuf.st_mtime > statbuf.st_atime) {
- free (newmail);
+ free(newmail);
(void) puts (_("You have new mail."));
return;
}
}
- free (newmail);
+ free(newmail);
}
mailbox = getenv ("MAIL");