summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeremy Sowden <jeremy@azazel.net>2021-08-28 20:38:22 +0100
committerPablo Neira Ayuso <pablo@netfilter.org>2021-08-30 02:14:33 +0200
commit6b6893c45af157802732c4db81df19d88f7291c3 (patch)
treee4de3ca754361c7f5d957302dc9cfaf40f272435
parent931686d211731d0732770affc44c68c5b20643b8 (diff)
src: use calloc instead of malloc + memset.
Signed-off-by: Jeremy Sowden <jeremy@azazel.net> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
-rw-r--r--src/libipulog_compat.c3
-rw-r--r--src/libnetfilter_log.c6
2 files changed, 3 insertions, 6 deletions
diff --git a/src/libipulog_compat.c b/src/libipulog_compat.c
index 2d5b23a..99cd866 100644
--- a/src/libipulog_compat.c
+++ b/src/libipulog_compat.c
@@ -90,12 +90,11 @@ struct ipulog_handle *ipulog_create_handle(uint32_t gmask,
struct ipulog_handle *h;
unsigned int group = gmask2group(gmask);
- h = malloc(sizeof(*h)+PAYLOAD_SIZE);
+ h = calloc(1, sizeof(*h)+PAYLOAD_SIZE);
if (! h) {
ipulog_errno = IPULOG_ERR_HANDLE;
return NULL;
}
- memset(h, 0, sizeof(*h));
h->nfulh = nflog_open();
if (!h->nfulh)
goto out_free;
diff --git a/src/libnetfilter_log.c b/src/libnetfilter_log.c
index 339f286..7d37570 100644
--- a/src/libnetfilter_log.c
+++ b/src/libnetfilter_log.c
@@ -238,11 +238,10 @@ struct nflog_handle *nflog_open_nfnl(struct nfnl_handle *nfnlh)
struct nflog_handle *h;
int err;
- h = malloc(sizeof(*h));
+ h = calloc(1, sizeof(*h));
if (!h)
return NULL;
- memset(h, 0, sizeof(*h));
h->nfnlh = nfnlh;
h->nfnlssh = nfnl_subsys_open(h->nfnlh, NFNL_SUBSYS_ULOG,
@@ -398,11 +397,10 @@ nflog_bind_group(struct nflog_handle *h, uint16_t num)
if (find_gh(h, num))
return NULL;
- gh = malloc(sizeof(*gh));
+ gh = calloc(1, sizeof(*gh));
if (!gh)
return NULL;
- memset(gh, 0, sizeof(*gh));
gh->h = h;
gh->id = num;