summaryrefslogtreecommitdiff
path: root/pop3d/pop3d.c
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2009-08-13 21:44:53 +0300
committerSergey Poznyakoff <gray@gnu.org.ua>2009-08-13 21:44:53 +0300
commitf84bcd99f10ab957af4c84601f9aaaeb43de98b7 (patch)
tree3845717703532b3a89dc5f9e78439a952acf8ead /pop3d/pop3d.c
parent6ffef584f46e175b1ae29a1b152316dacc8a08fd (diff)
downloadmailutils-f84bcd99f10ab957af4c84601f9aaaeb43de98b7.tar.gz
mailutils-f84bcd99f10ab957af4c84601f9aaaeb43de98b7.tar.bz2
Improve memory allocation in pop3d.
* pop3d/pop3d.c (pop3d_alloc_die): New function. (main): Set mu_alloc_die_hook. (pop3d_mainloop): Use mu_alloc. * pop3d/pop3d.h: Include mailutils/alloc.h
Diffstat (limited to 'pop3d/pop3d.c')
-rw-r--r--pop3d/pop3d.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/pop3d/pop3d.c b/pop3d/pop3d.c
index 16fa21ef4..8b05ace34 100644
--- a/pop3d/pop3d.c
+++ b/pop3d/pop3d.c
@@ -301,9 +301,7 @@ pop3d_mainloop (int fd, FILE *infile, FILE *outfile)
/* Prepare the shared secret for APOP. */
{
char *local_hostname;
- local_hostname = malloc (MAXHOSTNAMELEN + 1);
- if (local_hostname == NULL)
- pop3d_abquit (ERR_NO_MEM);
+ local_hostname = mu_alloc (MAXHOSTNAMELEN + 1);
/* Get our canonical hostname. */
{
@@ -317,9 +315,7 @@ pop3d_mainloop (int fd, FILE *infile, FILE *outfile)
}
}
- md5shared = malloc (strlen (local_hostname) + 51);
- if (md5shared == NULL)
- pop3d_abquit (ERR_NO_MEM);
+ md5shared = mu_alloc (strlen (local_hostname) + 51);
snprintf (md5shared, strlen (local_hostname) + 50, "<%u.%u@%s>", getpid (),
(unsigned)time (NULL), local_hostname);
@@ -388,6 +384,12 @@ pop3d_connection (int fd, struct sockaddr *sa, int salen, void *data,
return 0;
}
+static void
+pop3d_alloc_die ()
+{
+ pop3d_abquit (ERR_NO_MEM);
+}
+
int
main (int argc, char **argv)
{
@@ -421,6 +423,8 @@ main (int argc, char **argv)
mu_m_server_set_default_port (server, 110);
mu_m_server_set_timeout (server, 600);
mu_m_server_set_strexit (server, mu_strexit);
+
+ mu_alloc_die_hook = pop3d_alloc_die;
if (mu_app_init (&argp, pop3d_argp_capa, pop3d_cfg_param,
argc, argv, 0, NULL, server))

Return to:

Send suggestions and report system problems to the System administrator.