]> git.ipfire.org Git - ipfire-2.x.git/blob - src/patches/dnsmasq/009-malloc_memset_calloc_for_efficiency.patch
BUG11177: pppoe password not required anymore
[ipfire-2.x.git] / src / patches / dnsmasq / 009-malloc_memset_calloc_for_efficiency.patch
1 From d6dce53e08b3a06be16d43e1bf566c6c1988e4a9 Mon Sep 17 00:00:00 2001
2 From: Simon Kelley <simon@thekelleys.org.uk>
3 Date: Mon, 11 Jul 2016 21:34:31 +0100
4 Subject: [PATCH] malloc(); memset() -> calloc() for efficiency.
5
6 ---
7 src/util.c | 10 +++-------
8 1 file changed, 3 insertions(+), 7 deletions(-)
9
10 diff --git a/src/util.c b/src/util.c
11 index 82443c9..211690e 100644
12 --- a/src/util.c
13 +++ b/src/util.c
14 @@ -244,13 +244,11 @@ unsigned char *do_rfc1035_name(unsigned char *p, char *sval)
15 /* for use during startup */
16 void *safe_malloc(size_t size)
17 {
18 - void *ret = malloc(size);
19 + void *ret = calloc(1, size);
20
21 if (!ret)
22 die(_("could not get memory"), NULL, EC_NOMEM);
23 - else
24 - memset(ret, 0, size);
25 -
26 +
27 return ret;
28 }
29
30 @@ -264,12 +262,10 @@ void safe_pipe(int *fd, int read_noblock)
31
32 void *whine_malloc(size_t size)
33 {
34 - void *ret = malloc(size);
35 + void *ret = calloc(1, size);
36
37 if (!ret)
38 my_syslog(LOG_ERR, _("failed to allocate %d bytes"), (int) size);
39 - else
40 - memset(ret, 0, size);
41
42 return ret;
43 }
44 --
45 1.7.10.4
46