Commit d6dce53e authored by Simon Kelley's avatar Simon Kelley

malloc(); memset() -> calloc() for efficiency.

parent 06093a9a
...@@ -244,13 +244,11 @@ unsigned char *do_rfc1035_name(unsigned char *p, char *sval) ...@@ -244,13 +244,11 @@ unsigned char *do_rfc1035_name(unsigned char *p, char *sval)
/* for use during startup */ /* for use during startup */
void *safe_malloc(size_t size) void *safe_malloc(size_t size)
{ {
void *ret = malloc(size); void *ret = calloc(1, size);
if (!ret) if (!ret)
die(_("could not get memory"), NULL, EC_NOMEM); die(_("could not get memory"), NULL, EC_NOMEM);
else
memset(ret, 0, size);
return ret; return ret;
} }
...@@ -264,12 +262,10 @@ void safe_pipe(int *fd, int read_noblock) ...@@ -264,12 +262,10 @@ void safe_pipe(int *fd, int read_noblock)
void *whine_malloc(size_t size) void *whine_malloc(size_t size)
{ {
void *ret = malloc(size); void *ret = calloc(1, size);
if (!ret) if (!ret)
my_syslog(LOG_ERR, _("failed to allocate %d bytes"), (int) size); my_syslog(LOG_ERR, _("failed to allocate %d bytes"), (int) size);
else
memset(ret, 0, size);
return ret; return ret;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment